Exemplo n.º 1
0
        public IActionResult Get(int orderId)
        {
            var order = _repository.GetOrderById(orderId);

            if (order != null)
            {
                return(Ok(_mapper.Map <IEnumerable <OrderItem>, IEnumerable <OrderItemViewModel> >(order.Items)));
            }
            return(NotFound());
        }
Exemplo n.º 2
0
        public IActionResult Get(int id)
        {
            try
            {
                var order = _repository.GetOrderById(id);

                if (order != null)
                {
                    return(Ok(_mapper.Map <Order, OrderViewModel>(order)));
                }
                else
                {
                    return(NotFound());
                }
            }
            catch (Exception ex)
            {
                _logger.LogInformation($"Failed to load orders: {ex}");
                return(BadRequest("Failed to get a products"));
            }
        }