コード例 #1
0
        public async Task <ActionResult <CinemaDomainModel> > DeleteAsync(int id)
        {
            CinemaDomainModel deletedCinema;

            try
            {
                deletedCinema = await _cinemaService.DeleteCinemaAsync(id);
            }
            catch (DbUpdateException e)
            {
                ErrorResponseModel errorResponse = new ErrorResponseModel
                {
                    ErrorMessage = e.InnerException.Message ?? e.Message,
                    StatusCode   = System.Net.HttpStatusCode.BadRequest
                };

                return(BadRequest(errorResponse));
            }

            if (deletedCinema == null)
            {
                ErrorResponseModel errorResponse = new ErrorResponseModel
                {
                    ErrorMessage = Messages.CINEMA_DOES_NOT_EXIST,
                    StatusCode   = System.Net.HttpStatusCode.BadRequest
                };

                return(BadRequest(errorResponse));
            }

            return(Accepted("cinemas//" + deletedCinema.Id, deletedCinema));
        }