using gehGassiApp.Domain.Common;
using Platform = gehGassiApp.Domain.Common.Platform;
namespace gehGassiApp.Domain.Subscriptions
{
///
/// Repräsentiert eine Buchung eines Abonnements durch einen AppUser
///
public class AppUserSubscription
{
///
/// Id des Abonnements des App-Users
///
public long Id { get; set; }
///
/// Id des Abonnements
///
public string SubscriptionId { get; set; }
///
/// Code des Abonnements
///
public string SubscriptionCode { get; set; }
///
/// Dauer des Abonnements
///
public SubscriptionLength SubscriptionLength { get; set; }
///
/// Preis des Abonnements in Euro
///
public decimal SubscriptionPrice { get; set; }
///
/// Art des Abonnements - für welchen Benutzer-Typ?
///
public AppMode SubscriptionAppMode { get; set; }
///
/// Name des Abonnements
///
public string SubscriptionName { get; set; }
///
/// Zeit in Tagen die als Toleranz bei Ablauf akzeptiert wird
///
public int SubscriptionGracePeriodInDays { get; set; }
///
/// Ist das Abonnement gültig?
///
public bool IsValid { get; set; }
///
/// Wann läuft das Abonnement ab?
///
public DateTimeOffset? ExpirationDate { get; set; }
///
/// Wann läuft das Abonnement ab? Mit Toleranzzeit
///
public DateTimeOffset? ExpirationDateWithGrace { get; set; }
///
/// Wann wurde das Abonnement zuletzt verlängert?
///
public DateTimeOffset? LastRenewalDate { get; set; }
///
/// Wurde das Abonnement manuell erstellt?
///
public bool Manual { get; set; }
///
/// Plattform auf der das Abonnement erstellt wurde
///
public Platform Platform { get; set; }
///
/// Wann wurde das Abonnement erstellt?
///
public DateTimeOffset Created { get; set; }
///
/// Helper to calculate the current expiration date for Android
///
/// DateTime
/// DateTime
public DateTime AddLenght(DateTime date)
{
switch (SubscriptionLength)
{
case SubscriptionLength.OneWeek:
return date.AddDays(7);
case SubscriptionLength.OneMonth:
return date.AddMonths(1);
case SubscriptionLength.ThreeMonths:
return date.AddMonths(3);
case SubscriptionLength.SixMonths:
return date.AddMonths(6);
case SubscriptionLength.OneYear:
return date.AddYears(1);
default:
return date;
}
}
}
}