Beispiel #1
0
        public async Task <ActionResult <OrderReadDTO> > GetOrder(int id)
        {
            var model = await _orderService.GetOrder(id);

            if (model == null)
            {
                return(NotFound());
            }

            var order = new OrderReadDTO
            {
                OrderId     = model.OrderId,
                CreatedAt   = model.CreatedAt,
                User        = model.User,
                OrderStatus = model.OrderStatus
            };

            return(Ok(order));
        }
        public async Task <ActionResult <OrderReadDTO> > GetOrderById(string id)
        {
            var order = await _orderRepo.GetOneOrder(id);

            if (order != null)
            {
                var orderDTO = new OrderReadDTO
                {
                    OrderId = order.OrderId,
                    UserId  = order.OrdererId,
                    Date    = order.Date,
                    Total   = order.Total
                };

                return(Ok(orderDTO)); //success return order
            }

            return(NotFound()); //Return 404 if no order found
        }