public IActionResult Get()
 {
     try
     {
         var username = User.Identity.Name;
         var list     = _mapper.Map <List <OrderViewModel> >(_repository.GetAllOrdersByUser(username));
         return(Ok(list));
     }
     catch (Exception ex)
     {
         _logger.LogError($"Failed to get orders:{ex}");
         return(BadRequest("Failed to get orders"));
     }
 }
Exemplo n.º 2
0
 public IActionResult Get(bool includeItems = true)
 {
     try
     {
         var username = User.Identity.Name;
         var results  = _repository.GetAllOrdersByUser(username, includeItems);
         return(Ok(_mapper.Map <IEnumerable <Order>, IEnumerable <OrderViewModel> >(results)));
     }
     catch (Exception ex)
     {
         _logger.LogError($"Failed to get error {ex}");
         return(BadRequest("Failed to get Orders"));
     }
 }