Ejemplo n.º 1
0
        public PaginationSet <CustomerViewModel> GetEmployeeList(HttpRequestMessage request, int?page, int?pageSize, int?filterCustomersColumn, string filter = null)
        {
            int currentPage     = page.Value;
            int currentPageSize = pageSize.Value;
            int columnfilter    = Convert.ToInt16(filterCustomersColumn);
            CustomerGridViewModel             responseData = _icommonservive.GetEmployeeList(currentPage, currentPageSize, columnfilter, filter);
            PaginationSet <CustomerViewModel> pagedSet     = new PaginationSet <CustomerViewModel>()
            {
                Page       = currentPage,
                TotalCount = responseData.totalCount,
                TotalPages = (int)Math.Ceiling((decimal)responseData.totalCount / currentPageSize),
                Items      = responseData.customerList
            };

            return(pagedSet);
        }
Ejemplo n.º 2
0
        public CustomerGridViewModel GetEmployeeList(int currentPage, int currentPageSize, int filterCustomersColumn, string filter = null)
        {
            CustomerGridViewModel customerViewModel = new CustomerGridViewModel();

            try
            {
                if (!string.IsNullOrEmpty(filter))
                {
                    var tempData = _userRepository.GetAll()
                                   //.OrderBy(c => c.ID)
                                   //.Skip(currentPage * currentPageSize)
                                   //.Take(currentPageSize)
                                   .ToList();
                    /////
                    if (filterCustomersColumn == 1)
                    {
                        tempData = tempData.Where(c => c.Name.ToLower().Contains(filter)).ToList();
                    }
                    else if (filterCustomersColumn == 2)
                    {
                        tempData = tempData.Where(c => c.Phone.ToLower().Contains(filter)).ToList();
                    }
                    else if (filterCustomersColumn == 3)
                    {
                        tempData = tempData.Where(c => c.Email.ToLower().Contains(filter)).ToList();
                    }
                    else if (filterCustomersColumn == 4)
                    {
                        try
                        {
                            var time = Convert.ToDateTime(filter);
                            tempData = tempData.Where(c => c.DOB.GetValueOrDefault() == time).ToList();
                        }
                        catch (Exception ex)
                        {
                            throw ex;
                        }
                    }
                    else if (filterCustomersColumn == 5)
                    {
                        tempData = tempData.Where(c => c.City.CityName.ToLower().Contains(filter)).ToList();
                    }

                    ////
                    customerViewModel.customerList = (from c in tempData
                                                      select new CustomerViewModel
                    {
                        ID = c.ID,
                        Name = c.Name,
                        Email = c.Email,
                        Phone = c.Phone,
                        DOB = c.DOB,
                        CityId = c.CityId,
                        ProfileImageURL = c.ProfileImageURL,
                        IsDeleted = c.IsDeleted,
                        CityName = c.City.CityName,
                    })
                                                     .ToList();

                    customerViewModel.totalCount = _userRepository.FindBy(c => c.Name.ToLower().Contains(filter))
                                                   .Skip(currentPage * currentPageSize)
                                                   .Take(currentPageSize).Count();
                }
                else
                {
                    var tempData = _userRepository.GetAll()
                                   .OrderBy(c => c.ID)
                                   .Skip(currentPage * currentPageSize)
                                   .Take(currentPageSize)
                                   .ToList();
                    customerViewModel.customerList = (from c in tempData
                                                      select new CustomerViewModel
                    {
                        ID = c.ID,
                        Name = c.Name,
                        Email = c.Email,
                        Phone = c.Phone,
                        DOB = c.DOB,
                        CityId = c.CityId,
                        ProfileImageURL = c.ProfileImageURL,
                        IsDeleted = c.IsDeleted,
                        CityName = c.City.CityName,
                    })
                                                     .ToList();
                    customerViewModel.totalCount = _userRepository.GetAll().Count();
                }
            }
            catch (Exception)
            {
            }
            return(customerViewModel);
        }