public async Task <List <OrdersVm> > Handle(GetOrdersListByUsernameQuery request, CancellationToken cancellationToken) { var orderList = await _orderRepository.GetOrderByUserName(request.UserName); return(_mapper.Map <List <OrdersVm> >(orderList)); }
public async Task <ActionResult <IEnumerable <OrdersVm> > > GetOrdersByUserName(string userName) { try { var query = new GetOrdersListByUsernameQuery(userName); var orders = await _mediator.Send(query); if (!orders.Any()) { return(NotFound()); } return(Ok(orders)); } catch (Exception ex) { _logger.LogError($"Error getting orders", ex); throw new Exception($"Error getting orders", ex); } }