Пример #1
0
        public bool Delete(int id)
        {
            var director = _repository.FindById(id);

            _repository.Delete(director);
            return(_repository.SaveChanges());
        }
        public IActionResult Delete(int id)
        {
            var director = _directorRepository.GetById(id);

            _directorRepository.Delete(director);

            return(RedirectToAction("Index"));
        }
        public IActionResult Delete(int directorId)
        {
            var deletedDirector = _directorRepository.Delete(directorId);

            if (deletedDirector == null)
            {
                return(NoContent());
            }

            return(Ok(deletedDirector));
        }
 public void Delete(int DirectorID)
 {
     try
     {
         _directorRepository.Delete(DirectorID);
         _logger.LogInformation(LoggerMessageDisplay.DirectorDeleted);
     }
     catch (Exception ex)
     {
         _logger.LogInformation(LoggerMessageDisplay.DirectorDeletedError, ex);
     }
 }
Пример #5
0
        public async Task <IActionResult> DeleteDirectorById(int id)
        {
            try
            {
                var director = await _repository.Get <Director>(id);

                if (director == null)
                {
                    return(BadRequest($"Could not delete director. Director with Id {id} was not found."));
                }
                await _repository.Delete <Director>(id);

                return(NoContent());
            }
            catch (Exception e)
            {
                var result = new { Status = StatusCodes.Status500InternalServerError, Data = $"Failed to delete the director. Exception thrown when attempting to delete data from the database: {e.Message}" };
                return(this.StatusCode(StatusCodes.Status500InternalServerError, result));
            }
        }
Пример #6
0
        public async Task <IActionResult> Delete(int id)
        {
            try
            {
                _logger.LogInfo("Delete started");
                if (id < 1)
                {
                    _logger.LogWarn("Empty request");
                    return(BadRequest());
                }
                var isExists = await _directorRepository.IsExists(id);

                if (!isExists)
                {
                    _logger.LogWarn("Director does not exists");
                    return(BadRequest());
                }
                var director = await _directorRepository.FindById(id);

                if (director == null)
                {
                    _logger.LogWarn("Director not found");
                    return(NotFound());
                }
                var isSuccess = await _directorRepository.Delete(director);

                if (!isSuccess)
                {
                    return(InternalError("Director deletion failed"));
                }
                _logger.LogInfo("Director deleted");
                return(NoContent());
            }
            catch (Exception ex)
            {
                return(InternalError($"Something went wrong: {ex.Message}"));
            }
        }
        public async Task <ActionResult> DeleteDirector(int id)
        {
            try
            {
                var existingDirector = await _directorRepository.GetDirectorById(id);

                if (existingDirector == null)
                {
                    return(NotFound($"Could not find a director with id {id}"));
                }

                _directorRepository.Delete(existingDirector);
                if (await _directorRepository.Save())
                {
                    return(NoContent());
                }
            }
            catch (Exception exception)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, $"Database Failure: {exception.Message}"));
            }
            return(BadRequest());
        }
Пример #8
0
 public void Delete(Director director)
 {
     _directorRepository.Delete(director);
 }
 public void Delete(Director entity)
 {
     _directorRepository.Delete(entity);
 }
 public async Task DeleteAndSave(int id)
 {
     _directorRepo.Delete(id);
     await _directorRepo.Save();
 }