using System;
using ShareeBike.Model.State;
using ShareeBike.MultilingualResources;
using ShareeBike.ViewModel.Bikes.Bike;
namespace ShareeBike.ViewModel
{
public class MyBikeInUseStateInfoProvider : IInUseStateInfoProvider
{
/// Gets reserved into display text.
/// Log unexpected states.
/// Display text
public string GetReservedInfo(
TimeSpan? remainingTime,
string stationId = null,
string code = null)
{
if (remainingTime == null)
{
// Remaining time is not available.
if (stationId == null)
{
if (string.IsNullOrEmpty(code))
{
// Code is not available
return AppResources.StatusTextReservationExpiredMaximumReservationTime;
}
return string.Format(AppResources.StatusTextReservationExpiredCodeMaxReservationTime, code);
}
if (string.IsNullOrEmpty(code))
{
return string.Format(AppResources.StatusTextReservationExpiredLocationMaxReservationTime, stationId);
}
return string.Format(AppResources.StatusTextReservationExpiredCodeLocationMaxReservationTime, code, stationId);
}
if (!string.IsNullOrEmpty(stationId))
{
if (!string.IsNullOrEmpty(code))
{
return string.Format(
AppResources.StatusTextReservationExpiredCodeLocationReservationTime,
code,
ViewModelHelper.GetStationName(stationId),
remainingTime.Value.Minutes);
}
return string.Format(
AppResources.StatusTextReservationExpiredLocationReservationTime,
ViewModelHelper.GetStationName(stationId),
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 stationId = null,
string code = null)
{
if (from == null)
{
return AppResources.StatusTextBooked;
}
if (!string.IsNullOrEmpty(code))
{
if (!string.IsNullOrEmpty(stationId))
{
return string.Format(
AppResources.StatusTextBookedCodeLocationSince,
code,
ViewModelHelper.GetStationName(stationId),
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));
}
}
}