public async Task ApplyShipperAsync(ApplyShipperDTO applyShipper) { foreach (var orderId in applyShipper.OrderIds) { var order = await FindByIdAsync(orderId); order.ShipperId = applyShipper.ShipperId; order.Status = OrderStatus.Delivering; } await _context.SaveChangesAsync(); }
public async Task <ActionResult> ApplyShipper(int id, [FromForm] ApplyShipperDTO applyShipper) { foreach (var orderId in applyShipper.OrderIds) { var order = await _orderService.FindByIdAsync(orderId); if (order == null) { return(NotFound($"Order {orderId} not exist!".ToString())); } } await _orderService.ApplyShipperAsync(applyShipper); return(NoContent()); }