Example #1
0
 public IActionResult Verify(CheckOutInputModel info)
 {
     if (ModelState.IsValid)
     {
         return(Ok(info));
     }
     return(BadRequest());
 }
Example #2
0
 public IActionResult Pay(CheckOutInputModel info)
 {
     if (ModelState.IsValid)
     {
         var user = _userManager.GetUserId(HttpContext.User);
         _checkOutService.AddOrder(info, user);
         return(Ok());
     }
     return(BadRequest());
 }
Example #3
0
        public void AddOrder(CheckOutInputModel info, string id)
        {
            var cart  = _cartService.GetCart(id);
            var order = new Order
            {
                UserId         = id,
                DateOfPurchase = System.DateTime.Today
            };

            var orderid = _orderRepo.WriteOrder(order);

            foreach (var n in cart)
            {
                var bio = new BooksInOrder
                {
                    OrderId  = orderid,
                    Title    = n.Title,
                    Price    = n.Price,
                    Quantity = n.Quantity
                };
                _orderRepo.AddBookOrderConnection(bio);
            }
            var cardNumber = "xxxxxxxxxxxx";

            cardNumber += info.CardNumber.Substring(12);
            var orderInfo = new OrderInfo
            {
                OrderId                = orderid,
                UserId                 = id,
                ShippingFirstName      = info.ShippingFirstName,
                ShippingLastName       = info.ShippingLastName,
                ShippingStreetName     = info.ShippingStreetName,
                ShippingHouseNumber    = info.ShippingHouseNumber,
                ShippingCity           = info.ShippingCity,
                ShippingZipCode        = info.ShippingZipCode,
                ShippingCountry        = info.ShippingCountry,
                BillingFirstName       = info.BillingFirstName,
                BillingLastName        = info.BillingLastName,
                BillingStreetName      = info.BillingStreetName,
                BillingHouseNumber     = info.BillingHouseNumber,
                BillingCity            = info.BillingCity,
                BillingZipCode         = info.BillingZipCode,
                BillingCounry          = info.BillingCountry,
                PaymentFullName        = info.FullName,
                PaymentCardNumber      = cardNumber,
                PaymentExpirationMonth = info.ExpirationMonth,
                PaymentExpirationYear  = info.ExpirationYear,
            };

            _orderRepo.AddOrderInfo(orderInfo);
            _cartService.ClearCart(id);
        }
Example #4
0
        public async Task <CheckoutModel> CreateModel(CheckOutInputModel checkOutInputModel, string command)
        {
            var cart = await _mediator.Send(CartContentRequest.Create());

            var jurisdictions       = JurisdictionManager.GetJurisdictions(JurisdictionManager.JurisdictionType.Tax);
            var jurisdictionContrys = jurisdictions.Jurisdiction;
            var contrys             = jurisdictionContrys.Select(x => new SelectEntry()
            {
                DisplayName = x.DisplayName, Key = x.CountryCode, Selected = false
            }).ToList();

            var checkoutModel = new CheckoutModel()
            {
                Customer = checkOutInputModel, Cart = cart, Step = NextStep(command), JurisdictionContrys = contrys
            };

            return(checkoutModel);
        }
Example #5
0
        public CheckOutInputModel GetShippingBillingViewModel(string id)
        {
            CheckOutInputModel       data            = new CheckOutInputModel();
            ShippingBillingViewModel shippingBilling = _userRepo.GetShippingBilling(id);

            if (shippingBilling != null)
            {
                data.ShippingFirstName   = shippingBilling.ShippingFirstName;
                data.ShippingLastName    = shippingBilling.ShippingLastName;
                data.ShippingStreetName  = shippingBilling.ShippingStreetName;
                data.ShippingHouseNumber = shippingBilling.ShippingHouseNumber;
                data.ShippingCity        = shippingBilling.ShippingCity;
                data.ShippingZipCode     = shippingBilling.ShippingZipCode;
                data.ShippingCountry     = shippingBilling.ShippingCountry;
                data.BillingFirstName    = shippingBilling.BillingFirstName;
                data.BillingLastName     = shippingBilling.BillingLastName;
                data.BillingStreetName   = shippingBilling.BillingStreetName;
                data.BillingHouseNumber  = shippingBilling.BillingHouseNumber;
                data.BillingCity         = shippingBilling.BillingCity;
                data.BillingZipCode      = shippingBilling.BillingZipCode;
                data.BillingCountry      = shippingBilling.BillingCountry;
            }
            return(data);
        }
Example #6
0
        public async Task <ActionResult> AddEmail(int contentId, string command, CheckOutInputModel checkOutInputModel)
        {
            if (command == "To address")
            {
                var request = new CreateOrUpdateCustomerRequest()
                {
                    Email = checkOutInputModel.email, familyName = checkOutInputModel.familyName, FirstName = checkOutInputModel.firstName
                };
                var customer = await _mediator.Send(request);
            }
            else if (command == "To payment")
            {
                var request = new SetAddressRequest()
                {
                    AddressLine1 = checkOutInputModel.address1,
                    AddressLine2 = checkOutInputModel.address2,
                    City         = checkOutInputModel.city,
                    CountryCode  = checkOutInputModel.contry,
                    Email        = checkOutInputModel.email,
                    PostCode     = checkOutInputModel.zip,
                    State        = checkOutInputModel.state,
                    FirstName    = checkOutInputModel.firstName,
                    LastName     = checkOutInputModel.familyName
                };

                var responce = await _mediator.Send(request);
            }

            var currentPage = _contentLoader.Get <CheckOutPage>(new ContentReference(contentId));

            var checkoutModel = await CreateModel(checkOutInputModel, command);

            var viewModel = await _viewModelFactory.Create(currentPage, checkoutModel);

            return(View("~/Features/CheckOut/CheckOutPage.cshtml", viewModel));
        }