コード例 #1
0
        public IActionResult DeleteReview(int directorId)
        {
            if (!directorRepository.DirectorExists(directorId))
            {
                return(NotFound(404));
            }

            var deleteReview = directorRepository.GetDirector(directorId);

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (directorRepository.GetMoviesByDirector(directorId).Count() > 0)
            {
                ModelState.AddModelError("", "there are movies associated and thus can't delete");
                return(StatusCode(409, ModelState));
            }
            if (!directorRepository.DeleteDirector(deleteReview))
            {
                ModelState.AddModelError("", "Something went wrong,Please try again");
                return(StatusCode(500, ModelState));
            }
            return(NoContent());
        }
コード例 #2
0
        public ActionResult DeleteConfirmed(int id)
        {
            Director movie = _directorRepository.GetDirectorById(id);

            _directorRepository.DeleteDirector(id);
            _directorRepository.Save();
            return(RedirectToAction("Index"));
        }
コード例 #3
0
 public async Task DeleteDirector(int DirectorId)
 {
     try
     {
         await _directorReposity.DeleteDirector(DirectorId);
     }
     catch (System.Exception ex)
     {
         throw ex;
     }
 }
コード例 #4
0
        public async Task <ActionResult <DirectorDTO> > DeleteDirector(int id)
        {
            var directorResult = await _directorRepository.DeleteDirector(id).ConfigureAwait(false);

            if (directorResult == null)
            {
                return(NotFound());
            }

            return(directorResult);
        }
コード例 #5
0
        public async Task <IActionResult> DeleteDirector(string id)
        {
            try
            {
                if (!Guid.TryParse(id, out Guid directorId))
                {
                    throw new GuidException("Invalid id", this.GetType().Name, "DeleteDirector", "400");
                }
                await _directorRepository.DeleteDirector(id);

                return(NoContent());
            }
            catch (MovieMindException e)
            {
                if (e.MovieMindError.Status.Equals("404"))
                {
                    return(NotFound(e.MovieMindError));
                }
                else
                {
                    return(BadRequest(e.MovieMindError));
                }
            }
        }
コード例 #6
0
 public void Delete(int directorId)
 {
     _directorRepository.DeleteDirector(directorId);
 }
コード例 #7
0
        public string DeleteDirector(int directorid)
        {
            int deletedirector = Task.Run <int>(async() => await DirectorRepository.DeleteDirector(directorid)).Result;

            return(deletedirector > 0 ? "Successfully deleted Director record" : "Deletion failed");
        }