Esempio n. 1
0
        public ActionResult AddMovie(Movie movie, string imdbId)
        {
            movie.Id = imdbId;
            movie.imdbRating = movie.imdbRating / 10; //Ful lösning

            using (var db = new DBModel())
            {
                if (db.Movies.Any(m => m.Id == movie.Id))
                {
                    return Json(new { success = false, message = movie.Title + " is already in the database." });
                }
                db.Movies.Add(movie);
                db.SaveChanges();
            }
            return Json(new { success = true, message = movie.Title + " was added to the database." });
        }