111 lines
3.3 KiB
C#

using gehGassiApp.Domain.Common;
using Platform = gehGassiApp.Domain.Common.Platform;
namespace gehGassiApp.Domain.Subscriptions
{
/// <summary>
/// Repräsentiert eine Buchung eines Abonnements durch einen AppUser
/// </summary>
public class AppUserSubscription
{
/// <summary>
/// Id des Abonnements des App-Users
/// </summary>
public long Id { get; set; }
/// <summary>
/// Id des Abonnements
/// </summary>
public string SubscriptionId { get; set; }
/// <summary>
/// Code des Abonnements
/// </summary>
public string SubscriptionCode { get; set; }
/// <summary>
/// Dauer des Abonnements
/// </summary>
public SubscriptionLength SubscriptionLength { get; set; }
/// <summary>
/// Preis des Abonnements in Euro
/// </summary>
public decimal SubscriptionPrice { get; set; }
/// <summary>
/// Art des Abonnements - für welchen Benutzer-Typ?
/// </summary>
public AppMode SubscriptionAppMode { get; set; }
/// <summary>
/// Name des Abonnements
/// </summary>
public string SubscriptionName { get; set; }
/// <summary>
/// Zeit in Tagen die als Toleranz bei Ablauf akzeptiert wird
/// </summary>
public int SubscriptionGracePeriodInDays { get; set; }
/// <summary>
/// Ist das Abonnement gültig?
/// </summary>
public bool IsValid { get; set; }
/// <summary>
/// Wann läuft das Abonnement ab?
/// </summary>
public DateTimeOffset? ExpirationDate { get; set; }
/// <summary>
/// Wann läuft das Abonnement ab? Mit Toleranzzeit
/// </summary>
public DateTimeOffset? ExpirationDateWithGrace { get; set; }
/// <summary>
/// Wann wurde das Abonnement zuletzt verlängert?
/// </summary>
public DateTimeOffset? LastRenewalDate { get; set; }
/// <summary>
/// Wurde das Abonnement manuell erstellt?
/// </summary>
public bool Manual { get; set; }
/// <summary>
/// Plattform auf der das Abonnement erstellt wurde
/// </summary>
public Platform Platform { get; set; }
/// <summary>
/// Wann wurde das Abonnement erstellt?
/// </summary>
public DateTimeOffset Created { get; set; }
/// <summary>
/// Helper to calculate the current expiration date for Android
/// </summary>
/// <param name="date">DateTime</param>
/// <returns>DateTime</returns>
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;
}
}
}
}