mirror of
https://dev.azure.com/TeilRad/sharee.bike%20App/_git/Code
synced 2024-12-23 07:36:31 +01:00
96 lines
3.5 KiB
C#
96 lines
3.5 KiB
C#
|
using System;
|
|||
|
using TINK.Model.State;
|
|||
|
using TINK.MultilingualResources;
|
|||
|
using TINK.ViewModel.Bikes.Bike;
|
|||
|
|
|||
|
namespace TINK.ViewModel
|
|||
|
{
|
|||
|
public class MyBikeInUseStateInfoProvider : IInUseStateInfoProvider
|
|||
|
{
|
|||
|
/// <summary> Gets reserved into display text. </summary>
|
|||
|
/// <todo>Log unexpeced states.</todo>
|
|||
|
/// <returns>Display text</returns>
|
|||
|
public string GetReservedInfo(
|
|||
|
TimeSpan? remainingTime,
|
|||
|
int? stationId = null,
|
|||
|
string code = null)
|
|||
|
{
|
|||
|
if (remainingTime == null)
|
|||
|
{
|
|||
|
// Reamining time is not available.
|
|||
|
if (stationId == null)
|
|||
|
{
|
|||
|
|
|||
|
if (string.IsNullOrEmpty(code))
|
|||
|
{
|
|||
|
// Code is not avilable
|
|||
|
return string.Format(AppResources.StatusTextReservationExpiredMaximumReservationTime, StateRequestedInfo.MaximumReserveTime.Minutes);
|
|||
|
}
|
|||
|
|
|||
|
return string.Format(AppResources.StatusTextReservationExpiredCodeMaxReservationTime, code, StateRequestedInfo.MaximumReserveTime.Minutes);
|
|||
|
}
|
|||
|
|
|||
|
if (string.IsNullOrEmpty(code))
|
|||
|
{
|
|||
|
return string.Format(AppResources.StatusTextReservationExpiredLocationMaxReservationTime, stationId, StateRequestedInfo.MaximumReserveTime.Minutes);
|
|||
|
}
|
|||
|
|
|||
|
return string.Format(AppResources.StatusTextReservationExpiredCodeLocationMaxReservationTime, code, stationId, StateRequestedInfo.MaximumReserveTime.Minutes);
|
|||
|
}
|
|||
|
|
|||
|
if (stationId.HasValue)
|
|||
|
{
|
|||
|
if (!string.IsNullOrEmpty(code))
|
|||
|
{
|
|||
|
return string.Format(
|
|||
|
AppResources.StatusTextReservationExpiredCodeLocationReservationTime,
|
|||
|
code,
|
|||
|
ViewModelHelper.GetStationName(stationId.Value),
|
|||
|
remainingTime.Value.Minutes);
|
|||
|
}
|
|||
|
|
|||
|
return string.Format(
|
|||
|
AppResources.StatusTextReservationExpiredLocationReservationTime,
|
|||
|
ViewModelHelper.GetStationName(stationId.Value),
|
|||
|
remainingTime.Value.Minutes);
|
|||
|
}
|
|||
|
|
|||
|
return string.Format(
|
|||
|
AppResources.StatusTextReservationExpiredRemaining,
|
|||
|
remainingTime.Value.Minutes);
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// Gets booked into display text.
|
|||
|
/// </summary>
|
|||
|
/// <todo>Log unexpeced states.</todo>
|
|||
|
/// <returns>Display text</returns>
|
|||
|
public string GetBookedInfo(
|
|||
|
DateTime? from,
|
|||
|
int? stationId = null,
|
|||
|
string code = null)
|
|||
|
{
|
|||
|
if (from == null)
|
|||
|
{
|
|||
|
return AppResources.StatusTextBooked;
|
|||
|
}
|
|||
|
|
|||
|
if (!string.IsNullOrEmpty(code))
|
|||
|
{
|
|||
|
if(stationId.HasValue)
|
|||
|
{
|
|||
|
return string.Format(
|
|||
|
AppResources.StatusTextBookedCodeLocationSince,
|
|||
|
code,
|
|||
|
ViewModelHelper.GetStationName(stationId.Value),
|
|||
|
from.Value.ToString(BikeViewModelBase.TIMEFORMAT));
|
|||
|
}
|
|||
|
|
|||
|
return string.Format(AppResources.StatusTextBookedCodeSince, code, from.Value.ToString(BikeViewModelBase.TIMEFORMAT));
|
|||
|
}
|
|||
|
|
|||
|
return string.Format(AppResources.StatusTextBookedSince, from.Value.ToString(BikeViewModelBase.TIMEFORMAT));
|
|||
|
}
|
|||
|
}
|
|||
|
}
|