public async Task<ActionResult> NewMovie(Movie movie) { if (ModelState.IsValid) { await movieService.NewMovieAsync(movie); return RedirectToAction("Index"); } ViewBag.Categories = new SelectList(await movieService.GetMovieCategories(), "Id", "Name"); return View(); }
/// <summary> /// Creates new movie. /// </summary> /// <param name="movie">Movie.</param> public async Task NewMovieAsync(Movie movie) { await movieRepository.NewMovieAsync(movie); }
/// <summary> /// Creates new movie. /// </summary> /// <param name="movie">Movie.</param> public async Task NewMovieAsync(Movie movie) { movie.Id = Guid.NewGuid(); try { movie.StatusId = MovieContext.Statuses.First(item => String.Equals(item.Name, "Available")).Id; movie.DateCreated = DateTime.Now; movie.DateUpdated = DateTime.Now; MovieContext.Movies.Add(movie); await MovieContext.SaveChangesAsync(); } catch (Exception e) { throw e; } }