2023-06-06 12:00:24 +02:00
|
|
|
using System;
|
2021-05-13 20:03:07 +02:00
|
|
|
using System.Threading.Tasks;
|
2022-08-30 15:42:25 +02:00
|
|
|
using Serilog;
|
|
|
|
using TINK.Model.Bikes.BikeInfoNS.BluetoothLock;
|
2021-05-13 20:03:07 +02:00
|
|
|
using TINK.Model.State;
|
|
|
|
|
|
|
|
namespace TINK.ViewModel.Bikes.Bike.BluetoothLock.RequestHandler
|
|
|
|
{
|
2022-09-06 16:08:19 +02:00
|
|
|
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.");
|
2021-05-13 20:03:07 +02:00
|
|
|
|
2022-09-06 16:08:19 +02:00
|
|
|
ErrorText = errorText;
|
2021-05-13 20:03:07 +02:00
|
|
|
|
2022-09-06 16:08:19 +02:00
|
|
|
Log.Error($"{errorText}. Copri state is {copriState} and lock state is {lockingState}.");
|
|
|
|
}
|
2021-05-13 20:03:07 +02:00
|
|
|
|
2022-09-06 16:08:19 +02:00
|
|
|
/// <summary>View model to be used for progress report and unlocking/ locking view.</summary>
|
|
|
|
public IBikesViewModel BikesViewModel { get; }
|
2021-05-13 20:03:07 +02:00
|
|
|
|
2022-09-06 16:08:19 +02:00
|
|
|
public bool IsLockitButtonVisible => false;
|
2021-05-13 20:03:07 +02:00
|
|
|
|
2022-09-06 16:08:19 +02:00
|
|
|
public string LockitButtonText => GetType().Name;
|
2021-05-13 20:03:07 +02:00
|
|
|
|
2022-09-06 16:08:19 +02:00
|
|
|
public bool IsConnected => false;
|
2021-05-13 20:03:07 +02:00
|
|
|
|
2022-09-06 16:08:19 +02:00
|
|
|
public bool IsButtonVisible => false;
|
2021-05-13 20:03:07 +02:00
|
|
|
|
2022-09-06 16:08:19 +02:00
|
|
|
public string ButtonText => GetType().Name;
|
2021-05-13 20:03:07 +02:00
|
|
|
|
2023-06-06 12:00:24 +02:00
|
|
|
/// <summary> Gets if the bike has to be removed after action has been completed. </summary>
|
2022-09-06 16:08:19 +02:00
|
|
|
public bool IsRemoveBikeRequired => false;
|
2021-05-13 20:03:07 +02:00
|
|
|
|
2022-09-06 16:08:19 +02:00
|
|
|
public string ErrorText { get; }
|
2021-05-13 20:03:07 +02:00
|
|
|
|
2022-09-06 16:08:19 +02:00
|
|
|
public async Task<IRequestHandler> HandleRequestOption2()
|
|
|
|
{
|
|
|
|
Log.ForContext<InvalidState>().Error($"Click of unsupported button {nameof(HandleRequestOption2)} detected.");
|
|
|
|
return await Task.FromResult<IRequestHandler>(this);
|
|
|
|
}
|
2021-05-13 20:03:07 +02:00
|
|
|
|
2022-09-06 16:08:19 +02:00
|
|
|
public async Task<IRequestHandler> HandleRequestOption1()
|
|
|
|
{
|
|
|
|
Log.ForContext<InvalidState>().Error($"Click of unsupported button {nameof(HandleRequestOption1)} detected.");
|
|
|
|
return await Task.FromResult<IRequestHandler>(this);
|
|
|
|
}
|
|
|
|
}
|
2021-05-13 20:03:07 +02:00
|
|
|
}
|