public async Task <IActionResult> DeleteStockItemAsync(int id) { Logger?.LogDebug("'{0}' has been invoked", nameof(DeleteStockItemAsync)); var response = new Response(); try { var entity = await webAPIContext.GetStockItemsAsync(new StockItem(id)); if (entity == null) { return(NotFound()); } webAPIContext.Remove(entity); await webAPIContext.SaveChangesAsync(); } catch (Exception ex) { response.DidError = true; response.ErrorMessage = "There was an internal error, please contact to technical support."; Logger?.LogCritical("There was an error on '{0}' invocation: {1}", nameof(DeleteStockItemAsync), ex); } return(response.toHttpResponse()); }