Пример #1
0
        public ActionResult Checkout(Cart cart, string returnUrl)
        {
            if (cart.Lines.Count() == 0)
            {
                return(RedirectToAction(nameof(Index), new { returnUrl }));
            }
            ViewModels.CartSummaryViewModel cartSummaryVM = new ViewModels.CartSummaryViewModel();
            ShippingDetails shippingDetails = new ShippingDetails();
            Regions         defaultResult   = shippingDetails
                                              .GetCustomerData(System.Web.HttpContext.Current.User.Identity.GetUserId <int>())
                                              .Where(x => x.IsDefault)
                                              .FirstOrDefault();

            List <Regions> regionsList = shippingDetails.GetCustomerData(System.Web.HttpContext.Current.User.Identity.GetUserId <int>());

            ViewBag.RegionsList = new SelectList(regionsList, "RegionId", "RegionId");
            cartSummaryVM       = new ViewModels.CartSummaryViewModel
            {
                RegionId           = defaultResult.RegionId,
                City               = defaultResult.City,
                CompanyName        = defaultResult.Customers.CompanyName,
                Country            = defaultResult.Country,
                Email              = defaultResult.Customers.ApplicationUser.Email,
                Street             = defaultResult.Street,
                SelectedDeliveryId = cartSummaryVM.SelectedDeliveryId
            };
            return(View(nameof(Checkout), cartSummaryVM));
        }
        public CartSummaryViewModel()
        {
            ShippingDetails shippingDetails = new ShippingDetails();

            _deliveries = shippingDetails.GetDeliveries();
            _regions    = shippingDetails.GetCustomerData(System.Web.HttpContext.Current.User.Identity.GetUserId <int>());
        }
Пример #3
0
        public PartialViewResult GetAddressData(int RegionId)
        {
            ViewModels.CartSummaryViewModel cartSummaryVM = new ViewModels.CartSummaryViewModel();
            ShippingDetails shippingDetails = new ShippingDetails();
            List <Regions>  regionsList     = shippingDetails.GetCustomerData(System.Web.HttpContext.Current.User.Identity.GetUserId <int>());
            Regions         region          = regionsList.Where(x => x.RegionId == RegionId).FirstOrDefault();

            cartSummaryVM = new ViewModels.CartSummaryViewModel()
            {
                City               = region.City,
                CompanyName        = region.Customers.CompanyName,
                Country            = region.Country,
                Email              = region.Customers.ApplicationUser.Email,
                RegionId           = region.RegionId,
                SelectedDeliveryId = cartSummaryVM.SelectedDeliveryId,
                Street             = region.Street
            };
            return(PartialView("_CheckoutContent", cartSummaryVM));
        }