public virtual ActionResult New(GenreManagementViewModel viewModel) { var genre = ManagementMapper.GetGenreModel(viewModel); using (var repository = RepositoryFactory.GetGenreRepository()) { repository.AddOrUpdate(genre); repository.SaveChanges(); } CacheHelper.ClearCachedGenres(); return(RedirectToAction("Details", "Genres", new { area = "Content", id = genre.Id })); }
public ActionResult Edit(GenreManagementViewModel viewModel) { if (!ModelState.IsValid) { return(RedirectToAction("List", "Genres", new { Area = "Content" })); } var genreModel = ManagementMapper.GetGenreModel(viewModel); using (var repo = RepositoryFactory.GetGenreRepository()) { repo.AddOrUpdate(genreModel); repo.SaveChanges(); } CacheHelper.ClearCachedGenres(); return(RedirectToAction("Details", "Genres", new { Area = "Content", id = viewModel.Id })); }