public async Task <ActionResult <OrderDto> > CreateOrder(OrderDto orderDto) { Order order = orderDto.ToOrder(); await _orderService.AddAsync(order); return(CreatedAtAction(nameof(GetOrder), new { orderId = order.Id }, order.ToOrderDto())); }
public async Task <ActionResult> Add(OrderDto orderDto) { var order = orderDto.ToOrder(); db.Orders.Add(order); await db.SaveChangesAsync(); orderDto = new OrderDto(order); return(Ok(orderDto)); }
public async Task <ActionResult> Update(Guid orderId, OrderDto orderDto) { var order = await db.Orders.FirstOrDefaultAsync(e => e.Id == orderId); if (order == null) { return(NotFound()); } order = orderDto.ToOrder(order); await db.SaveChangesAsync(); return(NoContent()); }
public async Task <IActionResult> UpdateOrder(long orderId, OrderDto orderDto) { Order order = await _orderService.GetByIdAsync(orderId); if (order == null) { return(NotFound(orderId)); } orderDto.ToOrder(order); await _orderService.CommitAsync(); return(NoContent()); }
public async override Task <OrderDto> Update(OrderDto request, ServerCallContext context) { var order = await _orderApplication.UpdateOrderAsync(request.ToOrder()); return(order.ToOrderDto()); }
internal static Order ToOrder(this OrderDto orderDto) { return(orderDto.ToOrder(new Order())); }