85 lines
2.4 KiB
C#

using gehGassiApp.Domain.Common;
namespace gehGassiApp.Domain.Subscriptions
{
/// <summary>
/// Repräsentiert ein Abonnement
/// </summary>
public class Subscription
{
/// <summary>
/// Eindeutige Id
/// </summary>
public string Id { get; set; }
/// <summary>
/// Code des Abonnements
/// </summary>
public string Code { get; set; }
/// <summary>
/// Länge des Abonnements
/// </summary>
public SubscriptionLength Length { get; set; }
/// <summary>
/// Preis des Abonnements
/// </summary>
public decimal Price { get; set; }
/// <summary>
/// Art des Abonnements - für welchen Benutzer-Typ?
/// </summary>
public AppMode AppMode { get; set; }
/// <summary>
/// Zeit in Tagen die als Toleranz bei Ablauf akzeptiert wird
/// </summary>
public int GracePeriodInDays { get; set; }
/// <summary>
/// Ist das Abonnement ausgeblendet?
/// </summary>
public bool Hidden { get; set; }
/// <summary>
/// Optional: the Max registered date of the app user to see this subscription
/// </summary>
public DateTimeOffset? MaxRegisteredDate { get; set; }
/// <summary>
/// Name des Abonnements - übersetzt
/// </summary>
public string Name { get; set; }
/// <summary>
/// Beschreibung des Abonnements - übersetzt
/// </summary>
public string Description { 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 (Length)
{
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;
}
}
}
}