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

96 lines
2.5 KiB
C#
Raw Normal View History

2023-04-19 12:14:14 +02:00
using System;
2021-05-13 20:03:07 +02:00
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 MyBikeInUseStateInfoProvider : IInUseStateInfoProvider
{
/// <summary> Gets reserved into display text. </summary>
2023-06-06 12:00:24 +02:00
/// <todo>Log unexpected states.</todo>
2022-09-06 16:08:19 +02:00
/// <returns>Display text</returns>
public string GetReservedInfo(
TimeSpan? remainingTime,
string stationId = null,
string code = null)
{
if (remainingTime == null)
{
2023-06-06 12:00:24 +02:00
// Remaining time is not available.
2022-09-06 16:08:19 +02:00
if (stationId == null)
{
2021-05-13 20:03:07 +02:00
2022-09-06 16:08:19 +02:00
if (string.IsNullOrEmpty(code))
{
2023-04-19 12:14:14 +02:00
// Code is not available
2023-06-06 12:00:24 +02:00
return AppResources.StatusTextReservationExpiredMaximumReservationTime;
2022-09-06 16:08:19 +02:00
}
2021-05-13 20:03:07 +02:00
2023-06-06 12:00:24 +02:00
return string.Format(AppResources.StatusTextReservationExpiredCodeMaxReservationTime, code);
2022-09-06 16:08:19 +02:00
}
2021-05-13 20:03:07 +02:00
2022-09-06 16:08:19 +02:00
if (string.IsNullOrEmpty(code))
{
2023-06-06 12:00:24 +02:00
return string.Format(AppResources.StatusTextReservationExpiredLocationMaxReservationTime, stationId);
2022-09-06 16:08:19 +02:00
}
2021-05-13 20:03:07 +02:00
2023-06-06 12:00:24 +02:00
return string.Format(AppResources.StatusTextReservationExpiredCodeLocationMaxReservationTime, code, stationId);
2022-09-06 16:08:19 +02:00
}
2022-08-30 15:42:25 +02:00
2022-09-06 16:08:19 +02:00
if (!string.IsNullOrEmpty(stationId))
{
if (!string.IsNullOrEmpty(code))
{
return string.Format(
AppResources.StatusTextReservationExpiredCodeLocationReservationTime,
code,
ViewModelHelper.GetStationName(stationId),
remainingTime.Value.Minutes);
}
2021-05-13 20:03:07 +02:00
2022-09-06 16:08:19 +02:00
return string.Format(
AppResources.StatusTextReservationExpiredLocationReservationTime,
ViewModelHelper.GetStationName(stationId),
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>
2023-06-06 12:00:24 +02:00
/// <todo>Log unexpected states.</todo>
2022-09-06 16:08:19 +02:00
/// <returns>Display text</returns>
public string GetBookedInfo(
DateTime? from,
string stationId = 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))
{
if (!string.IsNullOrEmpty(stationId))
{
return string.Format(
AppResources.StatusTextBookedCodeLocationSince,
code,
ViewModelHelper.GetStationName(stationId),
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.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
}