sharee.bike-App/TINKLib/ViewModel/Bikes/Bike/BluetoothLock/RequestHandler/InvalidState.cs

63 lines
2.1 KiB
C#
Raw Normal View History

2021-05-13 20:03:07 +02:00
using Serilog;
using System;
using System.Threading.Tasks;
using TINK.Model.Bike.BluetoothLock;
using TINK.Model.State;
namespace TINK.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.");
State = copriState;
ErrorText = errorText;
Log.Error($"{errorText}. Copri state is {State} 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;
2021-06-26 20:57:55 +02:00
public string LockitButtonText => GetType().Name;
2021-05-13 20:03:07 +02:00
public bool IsConnected => false;
public InUseStateEnum State { get; }
private LockingState LockingState { get; }
public bool IsButtonVisible => false;
2021-06-26 20:57:55 +02:00
public string ButtonText => GetType().Name;
2021-05-13 20:03:07 +02:00
/// <summary> Gets if the bike has to be remvoed 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);
}
}
}