using System;
using ShareeBike.MultilingualResources;
using ShareeBike.ViewModel.Bikes.Bike;
namespace ShareeBike.ViewModel
{
public class BikeAtStationInUseStateInfoProvider : IInUseStateInfoProvider
{
/// Gets reserved into display text.
/// Log unexpected states.
/// Display text
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 AppResources.StatusTextReservationExpiredMaximumReservationTime;
}
return string.Format(AppResources.StatusTextReservationExpiredCodeMaxReservationTime, code);
}
if (!string.IsNullOrEmpty(code))
{
return string.Format(AppResources.StatusTextReservationExpiredCodeRemaining, code, remainingTime.Value.Minutes);
}
return string.Format(AppResources.StatusTextReservationExpiredRemaining, remainingTime.Value.Minutes);
}
/// Gets booked into display text.
/// Log unexpected states.
/// Display text
public string GetBookedInfo(
DateTime? from,
string station = null,
string code = null)
{
if (from == null)
{
return AppResources.StatusTextBooked;
}
if (!string.IsNullOrEmpty(code))
{
return string.Format(AppResources.StatusTextBookedCodeSince, code, from.Value.ToString(BikeViewModelBase.TIMEFORMAT));
}
return string.Format(AppResources.StatusTextBookedSince, from.Value.ToString(BikeViewModelBase.TIMEFORMAT));
}
}
}