sharee.bike-App/TINKLib/ViewModel/Bikes/Bike/BC/RequestHandler/Booked.cs

75 lines
2.3 KiB
C#
Raw Normal View History

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.BC;
2021-05-13 20:03:07 +02:00
using TINK.Model.User;
using TINK.MultilingualResources;
using TINK.View;
namespace TINK.ViewModel.Bikes.Bike.BC.RequestHandler
{
2022-09-06 16:08:19 +02:00
public class Booked : IRequestHandler
{
/// <summary>
/// If a bike is booked unbooking can not be done by though app.
/// </summary>
public bool IsButtonVisible => false;
2021-05-13 20:03:07 +02:00
2022-09-06 16:08:19 +02:00
/// <summary>
/// Gets the name of the button when bike is cancel reservation.
/// </summary>
public string ButtonText => AppResources.ActionReturn; // "Miete beenden"
2021-05-13 20:03:07 +02:00
2022-09-06 16:08:19 +02:00
/// <summary>
/// Reference on view service to show modal notifications and to perform navigation.
/// </summary>
protected IViewService ViewService { get; }
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
/// <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;
2021-05-13 20:03:07 +02:00
2022-09-06 16:08:19 +02:00
Log.ForContext<BikesViewModel>().Error("User selected booked bike {l_oId}.", SelectedBike.Id);
2021-05-13 20:03:07 +02:00
2022-09-06 16:08:19 +02:00
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");
2021-05-13 20:03:07 +02:00
2022-09-06 16:08:19 +02:00
BikesViewModel.IsIdle = true;
return this;
}
2021-05-13 20:03:07 +02:00
2022-09-06 16:08:19 +02:00
/// <summary>
/// Bike to display.
/// </summary>
protected IBikeInfoMutable SelectedBike { get; }
2021-05-13 20:03:07 +02:00
2022-09-06 16:08:19 +02:00
/// <summary>Gets the is connected state. </summary>
public bool IsConnected { get; set; }
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
/// <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.");
}
}
2021-05-13 20:03:07 +02:00
}