mirror of
https://dev.azure.com/TeilRad/sharee.bike%20App/_git/Code
synced 2024-11-16 15:16:34 +01:00
79 lines
2.8 KiB
C#
79 lines
2.8 KiB
C#
|
using Serilog;
|
|||
|
using System;
|
|||
|
using System.Threading.Tasks;
|
|||
|
using TINK.Model.Bikes.Bike.BC;
|
|||
|
using TINK.Model.State;
|
|||
|
using TINK.Model.User;
|
|||
|
using TINK.MultilingualResources;
|
|||
|
using TINK.View;
|
|||
|
|
|||
|
namespace TINK.ViewModel.Bikes.Bike.BC.RequestHandler
|
|||
|
{
|
|||
|
public class Booked : IRequestHandler
|
|||
|
{
|
|||
|
/// <summary> Gets the bike state. </summary>
|
|||
|
public InUseStateEnum State => InUseStateEnum.Booked;
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// If a bike is booked unbooking can not be done by though app.
|
|||
|
/// </summary>
|
|||
|
public bool IsButtonVisible => false;
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// Gets the name of the button when bike is cancel reservation.
|
|||
|
/// </summary>
|
|||
|
public string ButtonText => AppResources.ActionReturn; // "Miete beenden"
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// Reference on view servcie to show modal notifications and to perform navigation.
|
|||
|
/// </summary>
|
|||
|
protected IViewService ViewService { get; }
|
|||
|
|
|||
|
/// <summary>View model to be used for progress report and unlocking/ locking view.</summary>
|
|||
|
public IBikesViewModel BikesViewModel { get; }
|
|||
|
|
|||
|
/// <summary> Executes user request to cancel reservation. </summary>
|
|||
|
public async Task<IRequestHandler> HandleRequest()
|
|||
|
{
|
|||
|
// Lock list to avoid multiple taps while copri action is pending.
|
|||
|
BikesViewModel.ActionText = AppResources.ActivityTextOneMomentPlease;
|
|||
|
BikesViewModel.IsIdle = false;
|
|||
|
|
|||
|
Log.ForContext<BikesViewModel>().Error("User selected booked bike {l_oId}.", SelectedBike.Id);
|
|||
|
|
|||
|
BikesViewModel.ActionText = string.Empty;
|
|||
|
await ViewService.DisplayAlert(
|
|||
|
string.Empty,
|
|||
|
"Rückgabe nur über Bordcomputer des Fahrrads durch Drücken der Taste 2 möglich!",
|
|||
|
"Ok");
|
|||
|
|
|||
|
BikesViewModel.IsIdle = true;
|
|||
|
return this;
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// Bike to display.
|
|||
|
/// </summary>
|
|||
|
protected IBikeInfoMutable SelectedBike { get; }
|
|||
|
|
|||
|
/// <summary>Gets the is connected state. </summary>
|
|||
|
public bool IsConnected { get; set; }
|
|||
|
|
|||
|
/// <summary> Gets if the bike has to be remvoed after action has been completed. </summary>
|
|||
|
public bool IsRemoveBikeRequired => false;
|
|||
|
|
|||
|
/// <param name="bikesViewModel">View model to be used for progress report and unlocking/ locking view.</param>
|
|||
|
public Booked(
|
|||
|
IBikeInfoMutable selectedBike,
|
|||
|
IViewService viewService,
|
|||
|
IBikesViewModel bikesViewModel,
|
|||
|
IUser activeUser)
|
|||
|
{
|
|||
|
SelectedBike = selectedBike;
|
|||
|
ViewService = viewService;
|
|||
|
BikesViewModel = bikesViewModel
|
|||
|
?? throw new ArgumentException($"Can not construct {GetType().Name}-object. {nameof(bikesViewModel)} must not be null.");
|
|||
|
}
|
|||
|
}
|
|||
|
}
|