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)); } }
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()); } }
public void Delete(int id) { _valueService.Delete(id); }
public async Task Delete(int id) { await _valueService.Delete(id); }
public async Task Delete_InvalidId_GetsException() { await _valueService.Delete(0); }