コード例 #1
0
        public ActionResult <Response <ActorDto> > CreateActor([FromBody] ActorDto actorDto, [FromQuery] List <int> movieIds)
        {
            try
            {
                ValidateActor(actorDto, movieIds);

                var actor = _service.CreateActor(actorDto, movieIds);
                Response <ActorDto> response = new Response <ActorDto>
                {
                    Payload = new Payload <ActorDto>
                    {
                        PayloadObject = new ActorDto
                        {
                            Id          = actor.Id,
                            LastName    = actor.LastName,
                            Name        = actor.Name,
                            Picture     = actor.Picture,
                            DateOfBirth = actor.DateOfBirth
                        }
                    }
                };
                return(CreatedAtRoute("GetActor", new { actorId = actor.Id }, response));
            }
            catch (ErrorDetails ex)
            {
                _logger.LogError(ex.Description, ex);
                Response <ActorDto> resp = new Response <ActorDto>
                {
                    Payload   = null,
                    Exception = ex
                };
                return(resp);
            }
        }