public async Task <int> DeleteAsync(int id) { Order order = await _orderRepo.GetByIdToEditAsync(id); if (order == null) { throw new ApiException(MessagesResource.ORDER_NOT_FOUND, 404); } int bookId = order.BookId; if (order.IsBorrowed || order.ReturnDate != null) { throw new ApiException(MessagesResource.ORDER_NOT_DELETABLE); } await _orderRepo.DeleteAsync(order); return(bookId); }