public async Task <IHttpActionResult> PutMovie(int id, Movie movie) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != movie.MovieId) { return(BadRequest()); } try { CreateMovieActorRelation(movie); movie.Actors.Clear(); db.Entry(movie).State = EntityState.Modified; await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!MovieExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <IHttpActionResult> PutProducer(int id, Producer producer) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != producer.ProducerId) { return(BadRequest()); } db.Entry(producer).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ProducerExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }