예제 #1
0
        public IHttpActionResult GetActorForMovie(int movieId, int actorId)
        {
            if (!UOW.Movies.Exist(movieId))
            {
                return(NotFound());
            }

            var actor = UOW.Actors.GetActorForMovie(movieId, actorId);

            if (actor == null)
            {
                return(NotFound());
            }

            var actorForMovieDTo = Mapper.ActorDtoFromActor(actor);

            return(Ok(actorForMovieDTo));
        }
예제 #2
0
        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));
        }