Esempio n. 1
0
        public IActionResult AddMovieMB(Movie film)
        {
            if (ModelState.IsValid)
            {
                MovieDB.Add(film);

                ViewData["Success"] = "Movie has been added!";
            }
            return(View());
        }
Esempio n. 2
0
        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());
        }