public RedirectToActionResult AddToShoppingCart(int itemId) { int qty; var item = _inventoryRepository.GetItem(itemId, out qty); if (qty != 0) { _shoppingCartRepository.AddItemToCart(item); } return(RedirectToAction("Index")); }
public RedirectToRouteResult AddItem(Guid cartId, string name, decimal?price, int?quantity) { // normally validation would go here var item = new Item { Id = Guid.NewGuid(), // only necessary for entity framework Name = name, Price = price ?? 0, Quantity = quantity ?? 0 }; _shoppingRepo.AddItemToCart(cartId, item); return(RedirectToAction("Cart", new { id = cartId })); }
public async Task AddItemToShoppingCart(int mobilePhoneId) { await GetShoppingCart(); await _repository.AddItemToCart(shoppingCart, mobilePhoneId); }