Exemple #1
0
 public ActionResult Add(int id)
 {
     // creates new shopping cart item if does not exist
     // increments quantity if already exists
     try
     {
         Customer            user    = this.getCustomer();
         ShoppingCartManager manager = new ShoppingCartManager();
         ShoppingCartItem    model   = manager.GetItemByFlowerId(id, user.Id);
         if (model == null)
         {
             model            = new ShoppingCartItem();
             model.FlowerId   = id;
             model.CustomerId = user.Id;
             model.Quantity   = 1;
             manager.CreateItem(model);
         }
         else
         {
             // increment
             model.Quantity++;
             manager.UpdateItem(model.Id, model);
         }
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }