public async Task <ActionResult> Delete(int id) { int orderId; try { orderId = (await _orderDetailService.GetItemAsync(id)).OrderId; await _orderDetailService.DeleteAsync(id); } catch (ServiceException e) { throw new WebUiException($"Ошибка в контроллере {nameof(OrderDetailController)} в методе {nameof(Delete)}", e); } return(RedirectToAction("Edit", "Order", new { id = orderId })); }
// e.g. DELETE odata/Products(37) public async Task <IActionResult> Delete([FromODataUri] int key) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var result = await _orderDetailService.DeleteAsync(key); if (!result) { return(NotFound()); } await _unitOfWork.SaveChangesAsync(); return(StatusCode((int)HttpStatusCode.NoContent)); }