public IHttpActionResult AddActor(int movieId, [FromBody] PostActorDTO actorDTO) { if (!UOW.Movies.Exist(movieId)) { return(NotFound()); } var actor = Mapper.ActorFromPostActorDto(actorDTO); actor.MovieId = movieId; UOW.Actors.Add(actor); if (!UOW.Complete()) { return(StatusCode(HttpStatusCode.InternalServerError)); } var getActorDTO = Mapper.ActorDtoFromActor(actor); return(CreatedAtRoute("GetActorById", new { movieId = getActorDTO.MovieId, actorId = getActorDTO.Id }, getActorDTO)); }
public IHttpActionResult UpdateActorForMovie(int movieId, int actorId, [FromBody] PostActorDTO postActorDto) { if (!UOW.Movies.Exist(movieId)) { return(NotFound()); } var actorForMovie = UOW.Actors.GetActorForMovie(movieId, actorId); if (actorForMovie == null) { return(NotFound()); } actorForMovie = Mapper.ActorFromPostActorDto(actorForMovie, postActorDto); if (!UOW.Complete()) { return(StatusCode(HttpStatusCode.InternalServerError)); } return(StatusCode(HttpStatusCode.NoContent)); }