2021-05-13 20:03:07 +02:00
|
|
|
|
using System;
|
|
|
|
|
using TINK.Model.State;
|
|
|
|
|
using TINK.MultilingualResources;
|
|
|
|
|
using TINK.ViewModel.Bikes.Bike;
|
|
|
|
|
|
|
|
|
|
namespace TINK.ViewModel
|
|
|
|
|
{
|
2022-09-06 16:08:19 +02:00
|
|
|
|
public class BikeAtStationInUseStateInfoProvider : IInUseStateInfoProvider
|
|
|
|
|
{
|
|
|
|
|
/// <summary> Gets reserved into display text. </summary>
|
|
|
|
|
/// <todo>Log unexpeced states.</todo>
|
|
|
|
|
/// <returns>Display text</returns>
|
|
|
|
|
public string GetReservedInfo(
|
|
|
|
|
TimeSpan? remainingTime,
|
|
|
|
|
string station = null,
|
|
|
|
|
string code = null)
|
|
|
|
|
{
|
|
|
|
|
if (remainingTime == null)
|
|
|
|
|
{
|
|
|
|
|
// Remaining time not available.
|
|
|
|
|
if (string.IsNullOrEmpty(code))
|
|
|
|
|
{
|
|
|
|
|
// Reservation code not available
|
|
|
|
|
return string.Format(AppResources.StatusTextReservationExpiredMaximumReservationTime, StateRequestedInfo.MaximumReserveTime.Minutes);
|
|
|
|
|
}
|
2021-05-13 20:03:07 +02:00
|
|
|
|
|
2022-09-06 16:08:19 +02:00
|
|
|
|
return string.Format(AppResources.StatusTextReservationExpiredCodeMaxReservationTime, code, StateRequestedInfo.MaximumReserveTime.Minutes);
|
|
|
|
|
}
|
2021-05-13 20:03:07 +02:00
|
|
|
|
|
2022-09-06 16:08:19 +02:00
|
|
|
|
if (!string.IsNullOrEmpty(code))
|
|
|
|
|
{
|
|
|
|
|
return string.Format(AppResources.StatusTextReservationExpiredCodeRemaining, code, remainingTime.Value.Minutes);
|
|
|
|
|
}
|
2021-05-13 20:03:07 +02:00
|
|
|
|
|
2022-09-06 16:08:19 +02:00
|
|
|
|
return string.Format(AppResources.StatusTextReservationExpiredRemaining, remainingTime.Value.Minutes);
|
|
|
|
|
}
|
2021-05-13 20:03:07 +02:00
|
|
|
|
|
2022-09-06 16:08:19 +02:00
|
|
|
|
/// <summary> Gets booked into display text. </summary>
|
|
|
|
|
/// <todo>Log unexpeced states.</todo>
|
|
|
|
|
/// <returns>Display text</returns>
|
|
|
|
|
public string GetBookedInfo(
|
|
|
|
|
DateTime? from,
|
|
|
|
|
string station = null,
|
|
|
|
|
string code = null)
|
|
|
|
|
{
|
|
|
|
|
if (from == null)
|
|
|
|
|
{
|
|
|
|
|
return AppResources.StatusTextBooked;
|
|
|
|
|
}
|
2021-05-13 20:03:07 +02:00
|
|
|
|
|
2022-09-06 16:08:19 +02:00
|
|
|
|
if (!string.IsNullOrEmpty(code))
|
|
|
|
|
{
|
|
|
|
|
return string.Format(AppResources.StatusTextBookedCodeSince, code, from.Value.ToString(BikeViewModelBase.TIMEFORMAT));
|
|
|
|
|
}
|
2021-05-13 20:03:07 +02:00
|
|
|
|
|
2022-09-06 16:08:19 +02:00
|
|
|
|
return string.Format(AppResources.StatusTextBookedSince, from.Value.ToString(BikeViewModelBase.TIMEFORMAT));
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-05-13 20:03:07 +02:00
|
|
|
|
}
|