public ActionResult AddressAndPayment(FormCollection values) { var order = new Order(); TryUpdateModel(order); try { if (string.Equals(values["PromoCode"], PromoCode, StringComparison.OrdinalIgnoreCase) == false) { return(View(order)); } else { order.Username = User.Identity.Name; order.OrderDate = DateTime.Now; //Save Order _repo.Add(order); //Process the order _cart.CreateOrder(order, _cartid); return(RedirectToAction("Complete", new { id = order.OrderId })); } } catch { //Invalid - redisplay with errors return(View(order)); } }
public void AddToCart(Album album, string cartid) { var cartItem = _repo.Carts.SingleOrDefault( c => c.CartId == cartid && c.AlbumId == album.AlbumId); if (cartItem == null) { // Create a new cart item cartItem = new Cart { AlbumId = album.AlbumId, CartId = cartid, Count = 1, DateCreated = DateTime.Now }; _repo.Add(cartItem); } else { // Add one to the quantity cartItem.Count++; } }
public ActionResult Create(Album album) { try { //Save Album _repo.Add(album); return(Redirect("/")); } catch { //Invalid - redisplay with errors var viewModel = new StoreManagerViewModel { Album = album, Genres = _repo.Genres.ToList(), Artists = _repo.Artists.ToList() }; return(View(viewModel)); } }