public async Task <IActionResult> Delete(int id)
        {
            try
            {
                var selectedValue = await _valueService.GetByIdAsync(id);

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

                var valueToDeleted = new ValueForDeleteDto
                {
                    Id   = selectedValue.Id,
                    Name = selectedValue.Name
                };

                var deletedValue = _valueService.Delete(valueToDeleted);
                return(NoContent());
            }
            catch (Exception ex)
            {
                _logger.LogError(ex.Message);
                return(StatusCode(500));
            }
        }
示例#2
0
        public async Task <IActionResult> Delete(int id)
        {
            try
            {
                var customObject = await _valueService.Get(id);

                await _valueService.Delete(id);

                return(NoContent());
            }
            catch (KeyNotFoundException)
            {
                Response.Headers.Add("x-status-reason", $"No resource was found with the unique identifier '{id}'.");
                return(NotFound());
            }
        }
示例#3
0
 public void Delete(int id)
 {
     _valueService.Delete(id);
 }
 public async Task Delete(int id)
 {
     await _valueService.Delete(id);
 }
示例#5
0
 public async Task Delete_InvalidId_GetsException()
 {
     await _valueService.Delete(0);
 }