예제 #1
0
        public async Task <IActionResult> RemoveDirector([FromBody] MovieDirectorViewModel director)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var newDirector = Mapper.Map <MovieDirector>(director);

            _repository.RemoveDirector(newDirector);
            if (await _repository.SaveChangesAsync())
            {
                return(Ok("Director has been removed"));
            }

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