public AdminEditMovieViewModel(Movie movie, IEnumerable<Category> categories) { Movie = movie; if(movie.Category == null) { Categories = new SelectList(categories, Category.PropertyNames.Id, Category.PropertyNames.Name); } else { Categories = new SelectList(categories, Category.PropertyNames.Id, Category.PropertyNames.Name, movie.Category.Id); } }
public void AddToCart(ref ShoppingCart shoppingCart, Movie movie) { Check.Require(shoppingCart != null); Check.Require(movie != null); var cartItem = shoppingCart.CartItems.FirstOrDefault(x => x.Movie.Id == movie.Id); if(cartItem == null) { cartItem = new CartItem { Movie = movie, Quantity = 1 }; shoppingCart.CartItems.Add(cartItem); } else { cartItem.Quantity++; } }
public void AddToCart(ref ShoppingCart shoppingCart, Movie movie) { Check.Require(shoppingCart != null); Check.Require(movie != null); var cartItem = shoppingCart.CartItems.FirstOrDefault(x => x.Movie.Id == movie.Id); if (cartItem == null) { cartItem = new CartItem { Movie = movie, Quantity = 1 }; shoppingCart.CartItems.Add(cartItem); } else { cartItem.Quantity++; } if (_authenticationService.IsAuthenticated()) _cartItemRepository.SaveOrUpdate(cartItem); }
public void SaveOrUpdate(Movie movie) { if (_movies.Contains(movie)) { var index = _movies.IndexOf(movie); _movies.Remove(movie); _movies.Insert(index, movie); } else { _movies.Add(movie); } }
public void Delete(Movie movie) { _movies.Remove(movie); }
public void SaveOrUpdate(Movie movie) { Check.Require(null != movie); Session.SaveOrUpdate(movie); }
public void Delete(Movie movie) { Check.Require(null != movie); Session.Delete(movie); }
public ActionResult EditMovie(Movie movie, HttpPostedFileBase image) { if(ModelState.IsValid) { if(image != null) { movie.ImageMimeType = image.ContentType; movie.ImageData = new byte[image.ContentLength]; image.InputStream.Read(movie.ImageData, 0, image.ContentLength); } _moviesRepository.SaveOrUpdate(movie); TempData["message"] = string.Format("{0} has been saved", movie.Title); return RedirectToAction("Movies"); } var categories = _categoriesRepository.GetAll(); var viewModel = new AdminEditMovieViewModel(movie, categories); return View(viewModel); }