public PaymentDetail CalculatePrice(PriceDetail priceDetail)
        {
            var oneTime     = _paymentTypeQueryService.GetAll().FirstOrDefault(m => m.Type == PaymentType.OneTime.ToString()).Amount;
            var dailyAmount = _paymentTypeQueryService.GetAll().FirstOrDefault(m => m.Type == PaymentType.Premium.ToString()).Amount;
            var dailyPrice  = priceDetail.Day * dailyAmount;

            return(new PaymentDetail {
                OneTime = oneTime, Premium = dailyPrice
            });
        }
예제 #2
0
 public LogicResult <PaymentDetail> CalculatePrice(PriceDetail priceDetail)
 {
     try
     {
         var calculation   = this.GetCalculation(priceDetail.Type);
         var paymentDetail = calculation.CalculatePrice(priceDetail);
         return(LogicResult <PaymentDetail> .Succeed(paymentDetail));
     }
     catch (Exception exception)
     {
         return(LogicResult <PaymentDetail> .Failure(exception));
     }
 }
        public PaymentDetail CalculatePrice(PriceDetail priceDetail)
        {
            var premiumDailyAmount = _paymentTypeQueryService.GetAll().FirstOrDefault(m => m.Type == PaymentType.Premium.ToString()).Amount;
            var regularDailyAmount = _paymentTypeQueryService.GetAll().FirstOrDefault(m => m.Type == PaymentType.Regular.ToString()).Amount;
            var paymentDetail      = new PaymentDetail();
            var dayOver            = PaymentTypeDayOver.Specialized;

            if (priceDetail.Day > dayOver)
            {
                paymentDetail.Premium = premiumDailyAmount * dayOver;
                paymentDetail.Regular = regularDailyAmount * (priceDetail.Day - dayOver);

                return(paymentDetail);
            }
            else
            {
                paymentDetail.Premium = premiumDailyAmount * priceDetail.Day;
                return(paymentDetail);
            }
        }