public ActionResult addToCart(Cart cart, int quantity, int coffeeId)
 {
     Coffee coffee = coffeeRepo.Coffee.Where(c => c.CoffeeID == coffeeId).FirstOrDefault();
     if (quantity < 1 || quantity > 10 || coffee == null)
     {
         ModelState.AddModelError("", "quantity range is from 1 to 10 and Coffee must exist");
         if (Request.IsAjaxRequest())
         {
             Response.StatusCode = (int)HttpStatusCode.BadRequest;
             return Content("Error");
         }
     }
     if (ModelState.IsValid)
     {
         try
         {
             cart.addToCart(coffee, quantity, configRepo.Configuration.Where(c => c.Name.Trim() == "n").FirstOrDefault().Value);
         }
         catch (Exception ex)
         {
             if (Request.IsAjaxRequest())
             {
                 Response.StatusCode = (int)HttpStatusCode.BadRequest;
                 return Content(ex.Message);
             }
         }
     }
     CartTotalModelView model = new CartTotalModelView()
     {
         Cart = cart,
         M = this.M,
         X = this.X
     };
     if (Request.IsAjaxRequest()) return View("Summary", model);
     return View("Index", new CartModelView { Cart = cart });
 }
 public ViewResult Summary(Cart cart)
 {
     CartTotalModelView model = new CartTotalModelView()
     {
         Cart = cart,
         M = configRepo.Configuration.Where(c => c.Name.Trim() == "m").FirstOrDefault().Value,
         X = configRepo.Configuration.Where(c => c.Name.Trim() == "x").FirstOrDefault().Value
     };
     return View(model);
 }