using System;
using TINK.Model.Bikes.Bike;
using TINK.MultilingualResources;
namespace TINK.ViewModel.Bikes.Bike
{
///
/// View model for displaying tariff info.
///
public class TariffDescriptionViewModel
{
private TariffDescription Tariff { get; }
public TariffDescriptionViewModel(TariffDescription tariff)
{
Tariff = tariff;
}
public string Header
{
get
{
if (string.IsNullOrEmpty(FeeEuroPerHour)
&& string.IsNullOrEmpty(AboEuroPerMonth)
&& string.IsNullOrEmpty(FreeTimePerSession)
&& string.IsNullOrEmpty(MaxFeeEuroPerDay))
// No tariff description details available.
return string.Empty;
// Up to version MessageBikesManagementTariffDescriptionTariffHeaderNameId
#if USCSHARP9
return string.Format(AppResources.MessageBikesManagementTariffDescriptionTariffHeader, Tariff?.Name ?? "-");
#else
return string.Format(AppResources.MessageBikesManagementTariffDescriptionTariffHeader, Tariff?.Name ?? "-");
#endif
}
}
///
/// Costs per hour in euro.
///
public string FeeEuroPerHour
=> !double.IsNaN(Tariff.FeeEuroPerHour)
? string.Format("{0} {1}", Tariff.FeeEuroPerHour.ToString("0.00"), AppResources.MessageBikesManagementTariffDescriptionEuroPerHour)
: string.Empty;
///
/// Costs of the abo per month.
///
public string AboEuroPerMonth
=> !double.IsNaN(Tariff.AboEuroPerMonth)
? string.Format("{0} {1}", Tariff.AboEuroPerMonth.ToString("0.00"), AppResources.MessageBikesManagementTariffDescriptionEuroPerHour)
: string.Empty;
///
/// Free use time.
///
public string FreeTimePerSession
=> Tariff.FreeTimePerSession != TimeSpan.Zero
? string.Format("{0} {1}", Tariff.FreeTimePerSession.TotalHours, AppResources.MessageBikesManagementTariffDescriptionHour)
: string.Empty;
///
/// Max costs per day in euro.
///
public string MaxFeeEuroPerDay
=> !double.IsNaN(Tariff.FeeEuroPerHour)
? string.Format("{0} {1}", Tariff.MaxFeeEuroPerDay.ToString("0.00"), AppResources.MessageBikesManagementMaxFeeEuroPerDay)
: string.Empty;
/// Info about operator agb as HTML (i.g. text and hyperlink).
public string OperatorAgb => !string.IsNullOrEmpty(Tariff?.OperatorAgb)
? Tariff.OperatorAgb
: string.Empty;
}
}