コード例 #1
0
        public async Task <List <OrdersVm> > Handle(GetOrdersListByUsernameQuery request,
                                                    CancellationToken cancellationToken)
        {
            var orderList = await _orderRepository.GetOrderByUserName(request.UserName);

            return(_mapper.Map <List <OrdersVm> >(orderList));
        }
コード例 #2
0
        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);
            }
        }