Пример #1
0
        public async Task <HttpResponseMessage> GetAllCustomers(string searchCustomer, int pageNumber = 1, int pageSize = 10, string ordering = "Name")
        {
            CustomersFilter cFilter = new CustomersFilter(pageNumber, pageSize, ordering, searchCustomer);
            var             res     = await Service.GetAllCustomersAsync(cFilter);

            return(Request.CreateResponse(HttpStatusCode.OK, res));
        }
Пример #2
0
        void CustomerTileBar_ItemClick(object sender, TileItemEventArgs e)
        {
            if (e.Item.Tag is CustomersFilter)
            {
                viewCustomers.ActiveFilter.Clear();
                CustomersFilter filter = (CustomersFilter)e.Item.Tag;
                switch (filter)
                {
                case CustomersFilter.MyAccount:
                    viewCustomers.ActiveFilter.Add(viewCustomers.Columns["HomeOffice.State"], new ColumnFilterInfo(CriteriaOperator.Parse("HomeOffice.State == 'CA'")));
                    break;

                case CustomersFilter.JohnAccount:
                    viewCustomers.ActiveFilter.Add(viewCustomers.Columns["HomeOffice.State"], new ColumnFilterInfo(CriteriaOperator.Parse("HomeOffice.State == 'WA'")));
                    break;

                case CustomersFilter.TopStores:
                    viewCustomers.ActiveFilter.Add(viewCustomers.Columns["AnnualRevenue"], new ColumnFilterInfo(CriteriaOperator.Parse("AnnualRevenue >= 90000000000M")));
                    break;
                }
            }
            if (e.Item.Tag is string)
            {
                SetFilterString((string)e.Item.Tag);
            }
        }
 public async Task <IEnumerable <ICustomer> > GetAllAsync(CustomersFilter filter)
 {
     /*
      * return  await ((UnitOfWork)base._uow).DbContext.Customers
      *  .Where(item => String.IsNullOrEmpty(filter.SearchCustomer) ? item != null : item.Name.Contains(filter.SearchCustomer))
      *  .OrderBy(item => filter.Ordering)
      *  .ToPagedListAsync();
      * throw new System.NotImplementedException();
      */
     return(null);
 }
Пример #4
0
        public ActionResult GetCustomers(CustomersFilter filters)
        {
            using (DellAppDB db = new DellAppDB())
            {
                UserResults userResult = new UserResults();
                userResult.UserSys = db.UserSys.Where(p => p.Email.Equals(User.Identity.Name)).FirstOrDefault();

                if (userResult.UserSys.UserRoleId == 1)
                {
                    userResult.Customers = db.Customer.ToList();
                }

                return(View(userResult));
            }
        }
Пример #5
0
        /// <summary>
        /// Obtains a list of customers that match the specified criteria.
        /// </summary>
        /// <param name="filter">A customer filter</param>
        /// <returns>A list of all customers.</returns>
        public async Task <IList <Customer> > GetAllPagesAsync(CustomersFilter filter)
        {
            var items = new List <Customer>();

            filter = filter ?? new CustomersFilter();

            var pageOne = await GetDataAsync <PaginatedResponse <Customer> >(filter).ConfigureAwait(false);

            items.AddRange(pageOne.Items);
            if (pageOne.Pages > 1)
            {
                items.AddRange(await GetPageRangeAsync(2, pageOne.Pages, filter.PageSize, filter).ConfigureAwait(false));
            }

            return(items);
        }
Пример #6
0
        public async void TestGetCustomersWithCustomersFilters()
        {
            var marketplaceFilter = new CustomersFilter {
                MarketplaceId = 13
            };
            var stateFilter = new CustomersFilter {
                StateCode = "GA"
            };

            var customers = await Client.Customers.GetPageAsync(1, 100, marketplaceFilter) as List <Customer>;

            Assert.True(customers.Count > 0);

            customers = await Client.Customers.GetPageAsync(1, 100, stateFilter) as List <Customer>;

            Assert.True(customers.Count > 0);
        }
        public Task <List <Customer> > GetAll(CustomersFilter filter)
        {
            var query = Set.Where(x => !x.Archived);

            if (!string.IsNullOrWhiteSpace(filter.Name))
            {
                query = query.Where(x => x.CommercialName.StartsWith(filter.Name) || x.LegalName.StartsWith(filter.Name));
            }

            if (!string.IsNullOrWhiteSpace(filter.Cnpj))
            {
                var cnpj = new Cnpj(filter.Cnpj);
                query = query.Where(x => x.Cnpj == cnpj);
            }

            return(query.ToListAsync());
        }
Пример #8
0
        public async Task <CustomerListDto> Get([FromQuery] CustomersFilter filter)
        {
            var customer = await _customerRepository.GetAll(filter);

            return(new CustomerListDto(customer.Select(x => ConvertToDto(x)).ToList()));
        }
Пример #9
0
        public async Task <IList <Customer> > GetPageAsync(int page, int pageSize = 100, CustomersFilter filter = null)
        {
            if (page < 1)
            {
                throw new ArgumentException(nameof(page), "Cannot be a negative or zero");
            }
            if (pageSize < 1 || pageSize > 500)
            {
                throw new ArgumentOutOfRangeException(nameof(pageSize), "Should be in range 1..500");
            }

            filter = filter ?? new CustomersFilter();

            filter.Page     = page;
            filter.PageSize = pageSize;

            var response = await GetDataAsync <PaginatedResponse <Customer> >(filter).ConfigureAwait(false);

            return(response.Items);
        }
Пример #10
0
        public async Task <IList <Customer> > GetPageRangeAsync(int start, int end, int pageSize = 100, CustomersFilter filter = null)
        {
            if (start < 1)
            {
                throw new ArgumentException(nameof(start), "Cannot be a negative or zero");
            }
            if (start > end)
            {
                throw new ArgumentException(nameof(end), "Invalid page range");
            }
            if (pageSize < 1 || pageSize > 500)
            {
                throw new ArgumentOutOfRangeException(nameof(pageSize), "Should be in range 1..500");
            }

            var items = new List <Customer>();

            for (int i = start; i <= end; i++)
            {
                items.AddRange(await GetPageAsync(i, pageSize, filter).ConfigureAwait(false));
            }
            return(items);
        }
Пример #11
0
 public async Task <IEnumerable <ICustomer> > GetAllCustomersAsync(CustomersFilter filter)
 {
     return(await CustomerRepository.GetAllAsync(filter));
 }