public ActionResult AddToCart(ProductBasketViewModel pbvw) { Cart cart = new Cart(); cart.DateTime = DateTime.Now; cart.CustomerId = pbvw.CustomerId; cart.TotalAmount = pbvw.TotAmount; cart.TotalQty = pbvw.TotQty; _context.Carts.Add(cart); _context.SaveChanges(); return(RedirectToAction("Items")); }
public GroupedListViewModelBase( IExtendedDialogsService dialogsService, IDataService dataService) { _dialogsService = dialogsService; AddAllToCartCommand = new RelayCommand(AddAll); GenerateGroupCommand = new RelayCommand(GenerateGroup); _addGroupToCartCommand = new RelayCommand <ProductHeaderViewModel>(AddGroupToBasket); _generateItemCommand = new RelayCommand <ProductHeaderViewModel>(GenerateItem); _groupInfoCommand = new AsyncCommand <ProductHeaderViewModel>(GroupInfo); _addToCartCommand = new RelayCommand <ProductViewModel>(AddToBasket, CanAddToBasket); ProductListViewModel = new ProductListViewModel(dataService, _addGroupToCartCommand, _generateItemCommand, _addToCartCommand, _groupInfoCommand); ProductBasketViewModel = new ProductBasketViewModel(); }
public ActionResult Cart(int id) { var customer = _context.Customers.SingleOrDefault(m => m.Id == id); var userbasket = _context.UserBaskets.Where(m => m.CustomerId == id); var size = _context.Sizes.ToList(); var product = _context.Products.ToList(); var viewModel = new ProductBasketViewModel { Customer = customer, Size = size, UserBasket = userbasket, Product = product }; return(View(viewModel)); }