public ActionResult AddCart(int photo_id, int quantity) { int id = userRepo.GetUserId(User.Identity.Name); bool check = cartRepo.CheckAlreadyPresent(photo_id, id); if (check == true) { int x = cartRepo.updatecart(photo_id, id, quantity); return(RedirectToAction("CartData")); } else { if (id != null) { int i = cartRepo.addCart(photo_id, id, quantity); if (i >= 1) { int j = cartRepo.IncreeaseCartItem(id); if (j >= 1) { photorepo.DecreaseQuantity(photo_id); return(RedirectToAction("CartData")); } else { return(RedirectToAction("CartData")); } } else { return(RedirectToAction("CartData")); } } else { return(RedirectToAction("CartData")); } } }