Пример #1
0
 public ActionResult AddToCart(int itemId, int quantity)
 {
     var boughtItems = _repository.SelectItems(itemId);
     if (boughtItems == null)
     {
         var addToNewCart = _pos.ForNewItem(boughtItems, quantity, itemId);
         _repository.AddToNewCart(addToNewCart);
         _repository.DecreaseStock(itemId,quantity);
         return RedirectToAction("Customer");
     }
     else
     {
         var addToExistingCart = _pos.ForExistingItem(boughtItems, quantity);
         _repository.AddToExistingCart(addToExistingCart);
         _repository.DecreaseStock(itemId, quantity);
         return RedirectToAction("Customer");
     }
 }