sharee.bike-App/TINKLib/ViewModel/MyBikes/MyBikeViewModel.cs

96 lines
3.5 KiB
C#
Raw Normal View History

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
{
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,
2021-06-26 20:57:55 +02:00
string stationId = null,
2021-05-13 20:03:07 +02:00
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);
2022-08-30 15:42:25 +02:00
}
2021-06-26 20:57:55 +02:00
if (!string.IsNullOrEmpty(stationId))
2022-08-30 15:42:25 +02:00
{
2021-05-13 20:03:07 +02:00
if (!string.IsNullOrEmpty(code))
{
return string.Format(
AppResources.StatusTextReservationExpiredCodeLocationReservationTime,
code,
2021-06-26 20:57:55 +02:00
ViewModelHelper.GetStationName(stationId),
2021-05-13 20:03:07 +02:00
remainingTime.Value.Minutes);
}
return string.Format(
AppResources.StatusTextReservationExpiredLocationReservationTime,
2021-06-26 20:57:55 +02:00
ViewModelHelper.GetStationName(stationId),
2021-05-13 20:03:07 +02:00
remainingTime.Value.Minutes);
}
return string.Format(
2022-08-30 15:42:25 +02:00
AppResources.StatusTextReservationExpiredRemaining,
2021-05-13 20:03:07 +02:00
remainingTime.Value.Minutes);
}
/// <summary>
/// Gets booked into display text.
/// </summary>
/// <todo>Log unexpeced states.</todo>
/// <returns>Display text</returns>
public string GetBookedInfo(
DateTime? from,
2021-06-26 20:57:55 +02:00
string stationId = null,
2021-05-13 20:03:07 +02:00
string code = null)
{
if (from == null)
{
return AppResources.StatusTextBooked;
}
if (!string.IsNullOrEmpty(code))
2022-08-30 15:42:25 +02:00
{
if (!string.IsNullOrEmpty(stationId))
2021-05-13 20:03:07 +02:00
{
return string.Format(
2022-08-30 15:42:25 +02:00
AppResources.StatusTextBookedCodeLocationSince,
2021-05-13 20:03:07 +02:00
code,
2021-06-26 20:57:55 +02:00
ViewModelHelper.GetStationName(stationId),
2021-05-13 20:03:07 +02:00
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));
}
}
}