コード例 #1
0
ファイル: PaymentService.cs プロジェクト: revolve75/GameStore
        public PaymentModel CreatePaymentModel(string sessionKey, PaymentType paymentType,
                                               PaymentInfoModel paymentInfoModel)
        {
            var paymentModel = new PaymentModel
            {
                PaymentInfo = paymentInfoModel,
                PaymentType = paymentType,
            };

            ICollection <OrderItem> orderItems =
                _unitOfWork.OrderRepository.Get(order => order.SessionKey == sessionKey).First().OrderItems;

            paymentModel.OrderItems = Mapper.Map <ICollection <OrderItemModel> >(orderItems);

            var paymentStrategies = new Dictionary <PaymentType, IPaymentStrategy>
            {
                { PaymentType.Bank, new BankPaymentStrategy() },
                { PaymentType.Visa, new VisaPaymentStrategy() },
                { PaymentType.Terminal, new TerminalPaymentStrategy() },
            };

            PaymentStrategy = paymentStrategies[paymentType];

            PaymentModel finalPaymentModel = PaymentStrategy.GetFinalPaymentModel(paymentModel);

            return(finalPaymentModel);
        }