mirror of
https://dev.azure.com/TeilRad/sharee.bike%20App/_git/Code
synced 2024-11-06 11:06:26 +01:00
56 lines
1.8 KiB
C#
56 lines
1.8 KiB
C#
using System;
|
|
using System.Threading.Tasks;
|
|
using Serilog;
|
|
using ShareeBike.Model.Bikes.BikeInfoNS.BluetoothLock;
|
|
using ShareeBike.Model.State;
|
|
|
|
namespace ShareeBike.ViewModel.Bikes.Bike.BluetoothLock.RequestHandler
|
|
{
|
|
public class InvalidState : IRequestHandler
|
|
{
|
|
/// <param name="bikesViewModel">View model to be used for progress report and unlocking/ locking view.</param>
|
|
public InvalidState(
|
|
IBikesViewModel bikesViewModel,
|
|
InUseStateEnum copriState,
|
|
LockingState lockingState,
|
|
string errorText)
|
|
{
|
|
BikesViewModel = bikesViewModel
|
|
?? throw new ArgumentException($"Can not construct {GetType().Name}-object. {nameof(bikesViewModel)} must not be null.");
|
|
|
|
ErrorText = errorText;
|
|
|
|
Log.Error($"{errorText}. Copri state is {copriState} and lock state is {lockingState}.");
|
|
}
|
|
|
|
/// <summary>View model to be used for progress report and unlocking/ locking view.</summary>
|
|
public IBikesViewModel BikesViewModel { get; }
|
|
|
|
public bool IsLockitButtonVisible => false;
|
|
|
|
public string LockitButtonText => GetType().Name;
|
|
|
|
public bool IsConnected => false;
|
|
|
|
public bool IsButtonVisible => false;
|
|
|
|
public string ButtonText => GetType().Name;
|
|
|
|
/// <summary> Gets if the bike has to be removed after action has been completed. </summary>
|
|
public bool IsRemoveBikeRequired => false;
|
|
|
|
public string ErrorText { get; }
|
|
|
|
public async Task<IRequestHandler> HandleRequestOption2()
|
|
{
|
|
Log.ForContext<InvalidState>().Error($"Click of unsupported button {nameof(HandleRequestOption2)} detected.");
|
|
return await Task.FromResult<IRequestHandler>(this);
|
|
}
|
|
|
|
public async Task<IRequestHandler> HandleRequestOption1()
|
|
{
|
|
Log.ForContext<InvalidState>().Error($"Click of unsupported button {nameof(HandleRequestOption1)} detected.");
|
|
return await Task.FromResult<IRequestHandler>(this);
|
|
}
|
|
}
|
|
}
|