public IActionResult AddMovieMB(Movie film) { if (ModelState.IsValid) { MovieDB.Add(film); ViewData["Success"] = "Movie has been added!"; } return(View()); }
public IActionResult AddMovie(IFormCollection data) { //Validation code here try { Movie film = new Movie() { Title = data["title"], Director = data["director"], YearReleased = Convert.ToInt32(data["year"]), Genre = data["genre"], IMDBRating = Convert.ToDouble(data["rating"]) }; MovieDB.Add(film); ViewData["Success"] = "Movie has been added!"; } catch (Exception) { ViewData["Error"] = "Whoops, looks like something went wrong! :("; } return(View()); }