public IActionResult GetAllCustomer(CustomerQueryParameter customerQueryParameter)
        {
            _logger.LogInformation("------> GetAllCustomers version 1");
            var allcustomers = _customerRepository.GetAll(customerQueryParameter).ToList();

            var allCustomersDto = allcustomers.Select(x => Mapper.Map <CustomerDto>(x));

            Response.Headers.Add("x-Paging", JsonConvert.SerializeObject(new { totalCount = _customerRepository.Count() }));

            return(Ok(allCustomersDto));
        }
        public List <Customer> GetAll(CustomerQueryParameter customerQueryParameter)
        {
            List <Customer> customers = _context.Customers.OrderBy(customerQueryParameter.OrderBy, customerQueryParameter.Descending).ToList();

            if (customerQueryParameter.HasQuery)
            {
                customers = customers.Where(a => a.Firstname.ToLowerInvariant().Contains(customerQueryParameter.Query.ToLowerInvariant()) ||
                                            (a.Lastname.ToLowerInvariant().Contains(customerQueryParameter.Query.ToLowerInvariant()))
                                            ).ToList();
            }

            return(customers
                   .ToList().Skip(customerQueryParameter.PageCount * (customerQueryParameter.Page - 1))
                   .Take(customerQueryParameter.PageCount).ToList());
        }
Exemple #3
0
        private void search()
        {
            CustomerQueryParameter parameter = new CustomerQueryParameter();

            parameter.Name             = string.IsNullOrEmpty(NameFilter.Text) ? null : NameFilter.Text;
            parameter.GenderId         = int.Parse(GenderIdFilter.SelectedValue);
            parameter.CityId           = int.Parse(CityIdFilter.SelectedValue);
            parameter.RegionId         = int.Parse(RegionIdFilter.SelectedValue);
            parameter.ClassificationId = int.Parse(ClassificationIdFilter.SelectedValue);
            parameter.UserId           = int.Parse(UserIdFilter.SelectedValue);

            parameter.LastPurchaseStart = string.IsNullOrEmpty(LastPurchaseStartFilter.Text) ? (DateTime?)null : DateTime.Parse(LastPurchaseStartFilter.Text);
            parameter.LastPurchaseEnd   = string.IsNullOrEmpty(LastPurchaseEndFilter.Text) ? (DateTime?)null : DateTime.Parse(LastPurchaseEndFilter.Text);

            int skip = 0;
            int take = int.MaxValue;

            CustomerSearchResultGridView.PageSize = 10;

            List <View_Customer> list = StefaniniManager.CustomerManager.List(parameter, skip, take);

            Session["customerSearchResultList"] = list;
            this.showCustomerGridFromSession();
        }
        public List <View_Customer> List(CustomerQueryParameter parameter, int skipN, int takeN)
        {
            IQueryable <View_Customer> found = Context.View_Customer;

            if (!string.IsNullOrEmpty(parameter.Name))
            {
                found = found.Where(customer => customer.Customer.Contains(parameter.Name));
            }
            if (parameter.GenderId.HasValue && parameter.GenderId != int.MaxValue)
            {
                found = found.Where(customer => customer.GenderId == parameter.GenderId);
            }
            if (parameter.CityId.HasValue && parameter.CityId != int.MaxValue)
            {
                found = found.Where(customer => customer.CityId == parameter.CityId);
            }
            if (parameter.RegionId.HasValue && parameter.RegionId != int.MaxValue)
            {
                found = found.Where(customer => customer.RegionId == parameter.RegionId);
            }
            if (parameter.ClassificationId.HasValue && parameter.ClassificationId != int.MaxValue)
            {
                found = found.Where(customer => customer.ClassificationId == parameter.ClassificationId);
            }
            if (parameter.UserId.HasValue && parameter.UserId != int.MaxValue)
            {
                found = found.Where(customer => customer.SellerId == parameter.UserId);
            }

            if (parameter.LastPurchaseStart.HasValue && parameter.LastPurchaseEnd.HasValue)
            {
                found = found.Where(customer => customer.LastPurchase >= parameter.LastPurchaseStart.Value && customer.LastPurchase <= parameter.LastPurchaseEnd.Value);
            }

            return(found.ToList());
        }
        public PageCollection <CustomerModel> Page([FromUri] CustomerQueryParameter parameter)
        {
            var data = _customerQueryService.Page(parameter);

            return(data);
        }
Exemple #6
0
 public List <View_Customer> List(CustomerQueryParameter parameter, int skipN, int takeN)
 {
     return(StefaniniDataManager.CustomerDataManager.List(parameter, skipN, takeN));
 }