Exemple #1
0
        public async Task <IActionResult> Orders(OrderSearchViewModel data)
        {
            try
            {
                var orders = await _domainService.Get(data.OrderId, data.UserId, data.StartDate, data.EndDate, data.MinTotal, data.MaxTotal);

                var viewModelList = orders.Select(x => new OrderResultViewModel
                {
                    OrderId      = x.OrderId,
                    CreationDate = x.CreationDate,
                    OrderItems   = x.OrderItems.Select(y => new OrderItemResultViewModel
                    {
                        OrderItemId  = y.OrderItemId,
                        ProductId    = y.ProductId,
                        Amount       = y.Amount,
                        CurrentPrice = y.CurrentPrice
                    }).ToList()
                }).ToList();

                return(new OkObjectResult(viewModelList));
            }
            catch
            {
                return(BadRequest("Unable to retrieve orders."));
            }
        }