public void Process(char userSelection) { switch (userSelection) { case '1': // List movies _context = new MovieContext(); Console.WriteLine(); ConsoleTable.From <Movie>(_context.GetMovies()).Write(); break; case '2': // Ask user to enter movie details var movie = GetMovieDetails(); _context = new MovieContext(movie); _context.AddMovie(); Console.WriteLine($"\nYour movie {movie.Title} has been added!\n"); break; } }
public IActionResult Create( string title, Genre genre, DateTime releaseDate, string description, decimal price, bool preorder) { var modifiedReleaseDate = releaseDate; if (releaseDate == null) { modifiedReleaseDate = DateTime.Today; } #region snippet_TryValidateModel var movie = new Movie { Title = title, Genre = genre, ReleaseDate = modifiedReleaseDate, Description = description, Price = price, Preorder = preorder, }; var tb = TryValidateModel(movie); if (ModelState.IsValid) { _context.AddMovie(movie); _context.SaveChanges(); return(RedirectToAction(actionName: nameof(Index))); } return(View(movie)); #endregion }