Exemplo n.º 1
0
        public async Task <IActionResult> AddAward([FromBody] MovieAwardViewModel award)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var newAward = Mapper.Map <MovieAward>(award);

            _repository.AddAward(newAward);
            if (await _repository.SaveChangesAsync())
            {
                return(Created($"api/movie/award", Mapper.Map <MovieAwardViewModel>(newAward)));
            }

            return(BadRequest("Failed to save changes to the database"));
        }