Exemplo n.º 1
0
        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()));
        }
Exemplo n.º 2
0
        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));
        }
Exemplo n.º 3
0
        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());
        }
Exemplo n.º 4
0
        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());
        }
Exemplo n.º 5
0
        public async override Task <OrderDto> Update(OrderDto request, ServerCallContext context)
        {
            var order = await _orderApplication.UpdateOrderAsync(request.ToOrder());

            return(order.ToOrderDto());
        }
Exemplo n.º 6
0
 internal static Order ToOrder(this OrderDto orderDto)
 {
     return(orderDto.ToOrder(new Order()));
 }