public ActionResult Movies_Create([DataSourceRequest]DataSourceRequest request, MovieAdminViewModel model) { if (ModelState.IsValid && model != null) { //var movie = Mapper.Map<Movie>(model); var newId = 7; var movie = new Movie() { Title = model.Title, Year = model.Year, PosterId = model.PosterId, DirectorId = model.DirectorId, StudioId = model.StudioId, Summary = model.Summary, CreatedOn = model.CreatedOn, ModifiedOn = model.ModifiedOn, IsDeleted = model.IsDeleted, DeletedOn = model.DeletedOn }; var result = this.movies.Add(movie); newId = movie.Id; Mapper.Map(result, model); } return Json(new[] { model }.ToDataSourceResult(request, ModelState)); }
public ActionResult Movies_Destroy([DataSourceRequest]DataSourceRequest request, MovieAdminViewModel model) { var movie = this.movies.GetById(model.Id); this.movies.Delete(movie); return Json(new[] { model }.ToDataSourceResult(request, ModelState)); }
public async Task <IActionResult> CreateMovie() { IEnumerable <Role> roles = await roleService.GetAllRoles(); IEnumerable <GenreServiceModel> genres = await genreService.GetAllGenres(); MovieAdminViewModel model = new MovieAdminViewModel(); model.Prices = new List <PriceServiceModel>(); model.Genres = new List <GenreServiceModel>(); foreach (Role role in roles) { PriceServiceModel priceModel = new PriceServiceModel(); priceModel.RoleId = role.Id; priceModel.Role = role; model.Prices.Add(priceModel); } foreach (GenreServiceModel genre in genres) { GenreServiceModel genreModel = new GenreServiceModel(); genreModel.Name = genre.Name; genreModel.Id = genre.Id; model.Genres.Add(genreModel); } return(this.View(model)); }
public async Task <IActionResult> EditMovie(Guid id) { MovieAdminServiceModel movie = await this.moviesService.FindMovie(id); MovieAdminViewModel model = new MovieAdminViewModel { Id = movie.Id, Name = movie.Name, Year = movie.Year, Rating = movie.Rating, VideoPath = movie.VideoPath, PosterPath = movie.PosterPath, TrailerPath = movie.TrailerPath, Summary = movie.Summary, Prices = movie.Prices, Genres = movie.Genres }; return(this.View(model)); }
public async Task <IActionResult> CreateMovie(MovieAdminViewModel model) { if (!ModelState.IsValid) { return(this.View(model)); } await this.moviesService.Create( model.Name, model.Year, model.Rating, model.VideoPath, model.PosterPath, model.TrailerPath, model.Summary, model.Prices, model.Genres); TempData.AddSuccessMessage($"Movie '{model.Name}' successfully created"); return(RedirectToAction(nameof(CreateMovie))); }
public IActionResult EditMovie(MovieAdminViewModel model) { if (!ModelState.IsValid) { return(this.View(model)); } this.moviesService.EditMovie( model.Id, model.Name, model.Year, model.Rating, model.VideoPathEdit, model.PosterPath, model.TrailerPath, model.Summary, model.Prices, model.Genres); TempData.AddSuccessMessage($"Movie '{model.Name}' successfully edited !"); return(RedirectToAction(nameof(EditMovie))); }
public ActionResult Movies_Update([DataSourceRequest]DataSourceRequest request, MovieAdminViewModel model) { if (ModelState.IsValid && model != null) { var movie = new Movie() { Id = model.Id, Title = model.Title, Year = model.Year, PosterId = model.PosterId, DirectorId = model.DirectorId, StudioId = model.StudioId, Summary = model.Summary, CreatedOn = model.CreatedOn, ModifiedOn = model.ModifiedOn, IsDeleted = model.IsDeleted, DeletedOn = model.DeletedOn }; var result = this.movies.Update(movie).To<MovieAdminViewModel>().FirstOrDefault(); Mapper.Map(result, model); } return Json(new[] { model }.ToDataSourceResult(request, ModelState)); }
public ActionResult Movies_Destroy([DataSourceRequest] DataSourceRequest request, MovieAdminViewModel model) { var movie = this.movies.GetById(model.Id); this.movies.Delete(movie); return(Json(new[] { model }.ToDataSourceResult(request, ModelState))); }
public ActionResult Movies_Update([DataSourceRequest] DataSourceRequest request, MovieAdminViewModel model) { if (ModelState.IsValid && model != null) { var movie = new Movie() { Id = model.Id, Title = model.Title, Year = model.Year, PosterId = model.PosterId, DirectorId = model.DirectorId, StudioId = model.StudioId, Summary = model.Summary, CreatedOn = model.CreatedOn, ModifiedOn = model.ModifiedOn, IsDeleted = model.IsDeleted, DeletedOn = model.DeletedOn }; var result = this.movies.Update(movie).To <MovieAdminViewModel>().FirstOrDefault(); Mapper.Map(result, model); } return(Json(new[] { model }.ToDataSourceResult(request, ModelState))); }
public ActionResult Movies_Create([DataSourceRequest] DataSourceRequest request, MovieAdminViewModel model) { if (ModelState.IsValid && model != null) { //var movie = Mapper.Map<Movie>(model); var newId = 7; var movie = new Movie() { Title = model.Title, Year = model.Year, PosterId = model.PosterId, DirectorId = model.DirectorId, StudioId = model.StudioId, Summary = model.Summary, CreatedOn = model.CreatedOn, ModifiedOn = model.ModifiedOn, IsDeleted = model.IsDeleted, DeletedOn = model.DeletedOn }; var result = this.movies.Add(movie); newId = movie.Id; Mapper.Map(result, model); } return(Json(new[] { model }.ToDataSourceResult(request, ModelState))); }