Example #1
0
        public async Task <IActionResult> Patch([FromBody] MovieCastViewModel castMember)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var newCastMember = Mapper.Map <MovieCast>(castMember);

            _repository.UpdateMovieCast(newCastMember);
            if (await _repository.SaveChangesAsync())
            {
                return(Created($"api/moviecast/", Mapper.Map <MovieCastViewModel>(newCastMember)));
            }

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