Example #1
0
        public async Task <ActionResult <TrailerDTO> > PostActor(TrailerDTO trailerDto)
        {
            try
            {
                var mappedEntity = _mapper.Map <Trailer>(trailerDto);

                _trailerRepository.Add(mappedEntity);
                if (await _trailerRepository.Save())
                {
                    return(Created($"/api/v1.0/actors/{mappedEntity.TrailerID}", _mapper.Map <TrailerDTO>(mappedEntity)));
                }
            }
            catch (Exception e)
            {
                return(this.StatusCode(StatusCodes.Status500InternalServerError, $"Database Failure: {e.Message}"));
            }

            return(BadRequest());
        }