public void AddVideoToPackingSlip(string videoName)
        {
            PackingSlipDTO packingSlip = new PackingSlipDTO();

            packingSlip.PackingSlipDetails = videoName;

            _shipping.SaveShippingDetails(packingSlip);
        }
Пример #2
0
        public IHttpActionResult ProcessPayment([FromBody] PaymentDTO paymentDto)
        {
            if (paymentDto == null)
            {
                return(BadRequest());
            }

            bool isPaymentSuccessful = _payment.ProcessPayment(paymentDto);

            if (isPaymentSuccessful == true)
            {
                // If the Payment got successful, then we need to execute all the Services independently to process the Order.
                int packingSlipId = 0;
                foreach (var product in paymentDto.Order.Products)
                {
                    packingSlipId = _packingSlip.GeneratePackingSlip();
                    if (product.ProductType.Equals("Book"))
                    {
                        _packingSlipRoyaltyDep.CopyOriginalPackingSlipNumberForRoyDep(packingSlipId);
                    }
                }
                // comission payment to Agent
                _agent.DoAgentCommissonPayment(paymentDto);

                if (paymentDto.MembershipDTO.MembershipName.Equals("New Membership"))
                {
                    _membership.ActivateMembership(paymentDto.User);
                }
                else if (paymentDto.MembershipDTO.MembershipName.Equals("Upgrade Membership"))
                {
                    _membershipUpgrade.UpgradeMembership(paymentDto.User);
                }

                // The below code base is to demonstarte how can we send the parms to a service which can utlize another
                // service to do processing and ship the order.
                if (paymentDto.VideoSubscriptionDTO.VideoSubscriptionName.Equals("Learning to Ski"))
                {
                    _videoSubscription.CheckUserVideoSubscriptionPlans(paymentDto.VideoSubscriptionDTO.VideoSubscriptionName);
                }
                _shipping.SaveShippingDetails(paymentDto.PackingSlipDTO);

                // Send Email Notification in all cases , We can also frame the Message body based on the opertion we wanted to do.
                _emailNotification.SendEmailNotification();

                return(Ok(isPaymentSuccessful));
            }
            else
            {
                return(InternalServerError());
            }
        }