public async Task GetOrdersAsync_CanSearchByStatusAsync(OrderStatus status)
        {
            // Arrange
            var search = new SearchOrderParametersVm {
                Status = status
            };

            // Action
            var orders = await _service.GetOrdersAsync(search, null);

            // Assert
            Assert.NotEmpty(orders);
            Assert.All(orders, order => order.Status.Equals(status));
        }
        public async Task <ActionResult> Export([FromBody] SmartTableParam param)
        {
            var currentUser = await _workContext.GetCurrentUser();

            var search = param.Search.ToObject <SearchOrderParametersVm>();

            search.CanManageOrder = (await _authorizationService.AuthorizeAsync(User, Policy.CanManageOrder)).Succeeded;
            search.UserVendorId   = currentUser.VendorId;

            var orders = await _searchOrderService.GetOrdersAsync(search, param.Sort);

            using (var stream = new MemoryStream())
                using (var writer = new StreamWriter(stream, Encoding.UTF8))
                    using (var csvWriter = new CsvWriter(writer))
                    {
                        csvWriter.WriteRecords(orders);
                        writer.Flush();
                        var fileName = $"Orders-{DateTime.Now:dd/MM/yyyy}.csv";
                        return(File(stream.ToArray(), FileContentType.Binary, fileName));
                    }
        }