public async Task <IActionResult> Post([FromBody] MovieCastViewModel castMember) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var newCastMember = Mapper.Map <MovieCast>(castMember); _repository.AddMovieCast(newCastMember); if (await _repository.SaveChangesAsync()) { return(Created($"api/moviecast/", Mapper.Map <MovieCastViewModel>(newCastMember))); } return(BadRequest("Failed to save changes to the database")); }