Esempio n. 1
0
        public async Task <ActionResult> DeleteAdoProjectRequest(int id)
        {
            if (id < 1)
            {
                return(BadRequest());
            }

            try
            {
                _logger.LogInformation(ApiLogEvents.DeleteItem, $"{nameof(DeleteAdoProjectRequest)} Started");

                var repoObj = await _repository.GetId(id).ConfigureAwait(false);

                if (repoObj == null)
                {
                    _logger.LogWarning(ApiLogEvents.DeleteItemNotFound, $"{nameof(DeleteAdoProjectRequest)} not found");
                    return(NotFound());
                }

                _repository.Remove(repoObj);
                if (await _repository.SaveChangesAsync())
                {
                    return(NoContent());
                }
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, nameof(DeleteAdoProjectRequest), id);
                return(StatusCode(StatusCodes.Status500InternalServerError, ex?.Message));
            }
            return(null);
        }