Beispiel #1
0
        public IActionResult Get(int orderId)
        {
            var order = _repository.GetOrderById(User.Identity.Name, orderId);

            if (order != null)
            {
                return(Ok(_mapper.Map <IEnumerable <OrderItemViewModel> >(order.Items)));
            }
            return(NotFound());
        }
 public IActionResult Get(int id)
 {
     try
     {
         var order = _repository.GetOrderById(id);
         if (order != null)
         {
             return(Ok(_mapper.Map <OrderViewModel>(order)));
         }
         return(NotFound("Khong Thay"));
     }
     catch (Exception ex)
     {
         _logger.LogError($"Failed to get orders:{ex}");
         return(BadRequest("Failed to get orders"));
     }
 }
 public IActionResult Get(int id)
 {
     try
     {
         var order = _repository.GetOrderById(User.Identity.Name, id);
         if (order != null)
         {
             return(Ok(_mapper.Map <Order, OrderViewModel>(order)));
         }
         else
         {
             return(NotFound("Order not found."));
         }
     }
     catch (Exception ex)
     {
         _logger.LogError($"Failed to get error {ex}");
         return(BadRequest("Failed to get Order by ID"));
     }
 }