コード例 #1
0
        private decimal CalculatePrice(AthleteStatusType athleteStatusType, DateTime?statusExpirationDate, LicensingModelType licensingModelType)
        {
            decimal price;

            switch (licensingModelType)
            {
            case LicensingModelType.TwoDays:
                price = 2;
                break;

            case LicensingModelType.ThirtyDays:
                price = 4;
                break;

            case LicensingModelType.LifeLong:
                price = 8;
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            if (athleteStatusType == AthleteStatusType.Advanced && (statusExpirationDate == null || statusExpirationDate.Value >= DateTime.UtcNow))
            {
                price = price * 0.75m;
            }

            return(price);
        }
コード例 #2
0
 private AthleteStatus(AthleteStatusType type, ExpirationDate expirationDate)
 {
     Type            = type;
     _expirationDate = expirationDate ?? throw new ArgumentNullException(nameof(expirationDate));
 }