public ActionResult Checkout(ShopCartItemServiceClient cart, CustomerAddressService.ShoppingDetailsDTO shoppingDetails) { Factory factory = new Factory(); if (cart.Lines().Count() == 0) { ModelState.AddModelError("", "Sorry, your cart is empty!"); } if (addressService.GetStateProvince(shoppingDetails.City, shoppingDetails.Country) < 1) { ModelState.AddModelError("", "Incorrect City in country"); } var cartLine = factory.CreateCartLine(cart.Lines()); var details = factory.CreateShoppingDetails(shoppingDetails); if (ModelState.IsValid) { int userID = HttpContext.GetOwinContext() .GetUserManager <ApplicationUserManager>() .FindById(Convert.ToInt32(User.Identity.GetUserId())).BusinessEntityID; string email = HttpContext.GetOwinContext() .GetUserManager <ApplicationUserManager>() .FindById(Convert.ToInt32(User.Identity.GetUserId())).Email; orderService.ProcessOrder(cartLine.ToArray(), details, userID, email); cart.Clear(); return(View("Completed")); } else { ViewBag.Country = Countries; return(View(shoppingDetails)); } }
public ActionResult List(ShopCartItemServiceClient cart, string category, string subcategory, int page = 1, string name = null) { ProductsListView productsList = new ProductsListView { CurrentCategory = category, SubCategory = subcategory, ProductName = name, PagingInfo = new PagingInfo { CurrentPage = page, ItemsPerPage = PageSize, TotalItems = name == null?dataRepository.GetList().Where(x => x.SubCategory == subcategory).Count() : dataRepository.GetList().Where(x => x.Name.Contains(name)).Count() }, ProductCatalog = subcategory != null?dataRepository.GetList() .Where(x => x.SubCategory == subcategory || x.SubCategory == null) .OrderBy(x => x.ID) .Skip((page - 1) * PageSize) .Take(PageSize) : dataRepository.GetList().Where(x => x.Name.Contains(name)) .OrderBy(x => x.ID).Skip((page - 1) * PageSize).Take(PageSize), Cart = cart }; productsList.CountActualProduct(); return(View(productsList)); }
public ActionResult Index(ShopCartItemServiceClient cart, string returnUrl) { return(View(new ShopCartItemViewModel { ReturnUrl = returnUrl, Cart = cart })); }
public RedirectToRouteResult RemoveFromCart(ShopCartItemServiceClient cart, int productId, string returnUrl) { Factory factory = new Factory(); ProductService.ProductDTO product = productService.GetProduct(productId); var productDTO = factory.CreateProductDTO(product); if (productDTO != null) { cart.RemoveLine(productDTO); } return(RedirectToAction("Index", new { returnUrl })); }
public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext) { ShopCartItemServiceClient cart = null; if (controllerContext.HttpContext.Session != null) { cart = (ShopCartItemServiceClient)controllerContext.HttpContext.Session[sessionKey]; } if (cart == null) { cart = new ShopCartItemServiceClient(); if (controllerContext.HttpContext.Session != null) { controllerContext.HttpContext.Session[sessionKey] = cart; } } return(cart); }
public PartialViewResult Summary(ShopCartItemServiceClient check) { return(PartialView(check)); }