public Movie PatchMovie(Movie patchedMovie)
        {
            _dbContext.Movies.Update(patchedMovie);
            _dbContext.SaveChanges();

            return(patchedMovie);
        }
Пример #2
0
        public MovieImage InsertImage(MovieImage image)
        {
            _dbContext.Add(image);
            _dbContext.SaveChanges();

            return(image);
        }
        public void InsertDisplay(Display newDisplay)
        {
            _dbContext.Displays.AddAsync(newDisplay);

            // save changes returns exception when FK does not exist
            try
            {
                _dbContext.SaveChanges();
            }
            catch {}
        }
Пример #4
0
 public IActionResult Delete(int movieId)
 {
     try
     {
         Movie oldMovie = db.Movie.FirstOrDefault(m => m.MovieId == movieId);
         if (oldMovie == null)
         {
             return(NotFound($"No movie found with id {movieId}"));
         }
         else
         {
             db.Movie.Remove(oldMovie);
             db.SaveChanges();
         }
         return(Ok("movie deleted"));
     }
     catch (Exception e)
     {
         return(BadRequest(e));
     }
 }