示例#1
0
 public Customer2(int id, string name, CustomerType?type, CustomerType?type2, Address dir1)
 {
     Id    = id;
     Name  = name;
     Type  = type;
     Dir1  = dir1;
     Type2 = type2;
 }
 public CountCustomersSpecification(CustomerType?customerType, string territory, string accountNumber) : base()
 {
     Query
     .Where(c =>
            (string.IsNullOrEmpty(territory) || c.Territory == territory) &&
            (!customerType.HasValue || (customerType == CustomerType.Individual ?
                                        c is IndividualCustomer : c is StoreCustomer)
            ) &&
            (string.IsNullOrEmpty(accountNumber) || c.AccountNumber == accountNumber)
            );
 }
示例#3
0
        public GetAllCustomersSpecification(CustomerType?customerType) : base()
        {
            Query.Include(c => c.Addresses)
            .ThenInclude(a => a.Address);

            Query.Include("Person");
            Query.Include("Person.EmailAddresses");
            Query.Include("Contacts.ContactPerson.EmailAddresses");
            Query.Include("Contacts.ContactPerson.PhoneNumbers");

            Query
            .Where(c =>
                   (!customerType.HasValue || (customerType == CustomerType.Individual ?
                                               c is IndividualCustomer : c is StoreCustomer)
                   )
                   )
            .OrderBy(c => c.AccountNumber);
        }
        public List <Customer> GetAll(string name, CustomerType?customerType, int?cityId)
        {
            var customers = new List <Customer>();
            var query     = "EXEC GetCustomers";

            using (SQLHelper db = new SQLHelper(connectionString))
                using (SqlDataReader rdr = db.ExecDataReader(query, "@Name", getValueOrNull(name), "@CustomerType", getValueOrNull(customerType), "@CityId", getValueOrNull(cityId)))
                {
                    if (rdr.HasRows)
                    {
                        while (rdr.Read())
                        {
                            customers.Add(createCustomerObject(rdr));
                        }
                    }
                }
            return(customers);
        }
示例#5
0
        public IEnumerable <Customer> Get(string name, CustomerType?customerType = null, int?cityId = null)
        {
            var result = CustomerList.list;

            if (!String.IsNullOrWhiteSpace(name))
            {
                result = result.FindAll(i => i.FirstName == name || i.LastName == name);
            }
            if (customerType != null)
            {
                result = result.FindAll(i => i.CustomerType == customerType);
            }
            if (cityId != null)
            {
                result = result.FindAll(i => i.CityId == cityId);
            }
            return(result);
        }
示例#6
0
        public GetCustomersPaginatedSpecification(int pageIndex, int pageSize, CustomerType?customerType, string territory, string accountNumber) : base()
        {
            Query.Include(c => c.Addresses)
            .ThenInclude(a => a.Address);

            Query.Include("Person");
            Query.Include("Contacts.ContactPerson.EmailAddresses");
            Query.Include("Contacts.ContactPerson.PhoneNumbers");

            Query
            .Where(c =>
                   (string.IsNullOrEmpty(territory) || c.Territory == territory) &&
                   (!customerType.HasValue || (customerType == Entities.CustomerType.Individual ?
                                               c is IndividualCustomer : c is StoreCustomer)
                   ) &&
                   (string.IsNullOrEmpty(accountNumber) || c.AccountNumber == accountNumber)
                   )
            .Skip(pageIndex * pageSize)
            .Take(pageSize)
            .OrderBy(c => c.AccountNumber);
        }
示例#7
0
        public async Task <IEnumerable <Customer> > GetAsync([FromQuery] string nameLike,
                                                             [FromQuery] CustomerType?typeExact, [FromQuery] string countryExact,
                                                             [FromQuery] string provinceExact, [FromQuery] string cityExact, int?take, int?skip,
                                                             string orderBy, string orderMode)
        //ToDo:4 optionally include archived?
        {
            var query = new CustomersQuery
            {
                Take                    = take,
                Skip                    = skip,
                OrderBy                 = orderBy,
                OrderMode               = orderMode,
                FilterNameLike          = nameLike,
                FilterCustomerTypeExact = typeExact,
                FilterCountryExact      = countryExact,
                FilterProvinceExact     = provinceExact,
                FilterCityExact         = cityExact
            };

            //ToDo:2 query.AsLazy(); ??
            return(await _queryInvoker.Execute <CustomersQuery, Customer>(query));
        }
示例#8
0
        public async Task <IActionResult> Index(int?pageId, string territoryFilterApplied, string customerTypeFilterApplied)
        {
            CustomerType?customerType = null;

            if (customerTypeFilterApplied == "Individual")
            {
                customerType = CustomerType.Individual;
            }
            else if (customerTypeFilterApplied == "Store")
            {
                customerType = CustomerType.Store;
            }

            return(View(
                       await customerViewModelService.GetCustomers(
                           pageId ?? 0,
                           Constants.ITEMS_PER_PAGE,
                           territoryFilterApplied,
                           customerType
                           )
                       ));
        }
示例#9
0
            internal static IEnumerable <Customer> Get(string nameLike     = null, CustomerType?typeExact = null,
                                                       string countryExact = null, string provinceExact   = null, string cityExact = null, int?skip = null,
                                                       int?take            = null, string orderBy = null, string orderMode = null)
            {
                var dict = new Dictionary <string, string>
                {
                    { nameof(nameLike), nameLike },
                    { nameof(countryExact), countryExact },
                    { nameof(provinceExact), provinceExact },
                    { nameof(cityExact), cityExact },
                    { nameof(skip), skip?.ToString() },
                    { nameof(take), take?.ToString() },
                    { nameof(orderBy), orderBy },
                    { nameof(orderMode), orderMode }
                };

                if (typeExact.HasValue)
                {
                    dict.Add(nameof(typeExact), ((int)typeExact.Value).ToString());
                }

                return(Execute <IEnumerable <Customer> >("customers", Method.GET, queryParams: dict));
            }
        public async Task <CustomersIndexViewModel> GetCustomers(int pageIndex, int pageSize, string territory, CustomerType?customerType)
        {
            logger.LogInformation("GetCustomers called");
            var response = await customerApiClient.GetCustomersAsync(pageIndex, pageSize, territory, customerType);

            var vm = new CustomersIndexViewModel
            {
                Customers      = mapper.Map <List <CustomerViewModel> >(response.Customers),
                Territories    = await GetTerritories(false),
                CustomerTypes  = GetCustomerTypes(),
                PaginationInfo = new PaginationInfoViewModel()
                {
                    ActualPage   = pageIndex,
                    ItemsPerPage = response.Customers.Count,
                    TotalItems   = response.TotalCustomers,
                    TotalPages   = int.Parse(Math.Ceiling(((decimal)response.TotalCustomers / pageSize)).ToString())
                }
            };

            vm.PaginationInfo.Next     = (vm.PaginationInfo.ActualPage == vm.PaginationInfo.TotalPages - 1) ? "disabled" : "";
            vm.PaginationInfo.Previous = (vm.PaginationInfo.ActualPage == 0) ? "disabled" : "";

            return(vm);
        }
 public async Task <IActionResult> Index(int?pageId, string territoryFilterApplied, CustomerType?customerTypeFilterApplied, string accountNumber)
 {
     return(View(
                await customerService.GetCustomers(
                    pageId ?? 0,
                    Constants.ITEMS_PER_PAGE,
                    territoryFilterApplied,
                    customerTypeFilterApplied,
                    accountNumber
                    )
                ));
 }
        public List <Customer> GetAll(string name, CustomerType?customerType, int?cityId)
        {
            var result = _customerRepository.GetAll(name, customerType, cityId);

            return(result);
        }
 public IEnumerable <Customer> Get(CustomerType?customerType, bool?isRemoved)
 {
     throw new NotImplementedException();
 }