Пример #1
0
        //Get plan paged list
        public static PageData <PlanDTO> GetPlanPagedList(PagingInfo pagingInfo)
        {
            List <PlanDTO>     PlanDTOList = new List <PlanDTO>();
            PageData <PlanDTO> pageList    = new PageData <PlanDTO>();

            if (pagingInfo == null)
            {
                PagingInfo PagingInfoCreated = new PagingInfo();
                PagingInfoCreated.Page         = 1;
                PagingInfoCreated.Reverse      = false;
                PagingInfoCreated.ItemsPerPage = 1;
                PagingInfoCreated.Search       = "";
                PagingInfoCreated.TotalItem    = 0;

                pagingInfo = PagingInfoCreated;
            }
            if (pagingInfo.SortBy == "")
            {
                pagingInfo.SortBy = "Title";
            }

            PlanDTOList = GetPlanList(pagingInfo);

            IQueryable <PlanDTO> PlanDTOPagedList = PlanDTOList.AsQueryable();

            UnitOfWork uow   = new UnitOfWork();
            int        count = 0;

            if (pagingInfo.Search != "" && pagingInfo.Search != null)
            {
                bool IsDate = CommonService.IsDate(pagingInfo.Search);
                if (IsDate != true)
                {
                    count = 0;
                    count = uow.PlanRepo.GetAll().Where(e => (e.Title != null ? (e.Title.ToLower().Contains(pagingInfo.Search.ToLower())) : false) || e.Price.ToString().ToLower().Contains(pagingInfo.Search.ToLower()) || (e.Min.ToString() != null ? (e.Min.ToString().Contains(pagingInfo.Search.ToString())) : false) || e.Max.ToString().Contains(pagingInfo.Search) || (e.Tax.ToString() != null ? (e.Tax.ToString().ToLower().Contains(pagingInfo.Search.ToLower())) : false)).Count();//|| e.IsEcoupon.ToString().Contains(pagingInfo.Search)  //.OrderBy(e => e.Company);
                }
                else
                {
                    //DateTime date = Convert.ToDateTime(pagingInfo.Search);
                    //count = 0;
                    //count = uow.ClientRepo.GetAll().Where(e => e.RegisteredDate >= date && e.RegisteredDate < date.AddDays(1) && e.IsActive == IsActive && e.PartnerId == PartnerId).Count();
                }
            }
            else
            {
                count = uow.PlanRepo.GetAll().Count();
            }

            ////Sorting
            PlanDTOPagedList = PagingService.Sorting <PlanDTO>(PlanDTOPagedList, pagingInfo.SortBy, pagingInfo.Reverse);

            // paging
            if (PlanDTOPagedList.Count() > 0)
            {
                //var ContacDTOPerPage = PagingService.Paging<ClientDTO>(ClientDTOPagedList, pagingInfo.ItemsPerPage, pagingInfo.Page);
                pageList.Count = count;// ClientDTOPagedList.Count();


                List <PlanDTO> pagedPlanDTOList = new List <PlanDTO>();
                foreach (var item in PlanDTOPagedList)
                {
                    pagedPlanDTOList.Add(item);
                }
                pageList.Data = pagedPlanDTOList;
            }
            else
            {
                pageList.Data = null;
            }


            return(pageList);
        }
Пример #2
0
        //get plan list with search criteria
        public static List <PlanDTO> GetPlanList(PagingInfo pagingInfo)
        {
            List <PlanDTO> PlanDTO = new List <PlanDTO>();

            //List<PartnerDTO> PartnerDTO = new List<PartnerDTO>();

            try
            {
                UnitOfWork uow  = new UnitOfWork();
                int        skip = (pagingInfo.Page - 1) * pagingInfo.ItemsPerPage;
                int        take = pagingInfo.ItemsPerPage;

                IQueryable <Plan> Plan = uow.PlanRepo.GetAll().AsQueryable();// .Where(e => e.PartnerId == PartnerId && e.IsActive == IsActive).ToList().AsQueryable();//.OrderBy(e => e.Company);
                Plan = PagingService.Sorting <Plan>(Plan, pagingInfo.SortBy, pagingInfo.Reverse);
                Plan = Plan.Skip(skip).Take(take);

                List <PlanDTO> PlanDTOList = new List <PlanDTO>();

                if (Plan != null)
                {
                    foreach (var item in Plan)
                    {
                        PlanDTOList.Add(Transform.PlanToDTO(item));
                    }
                }

                if (PlanDTOList != null)
                {
                    if (pagingInfo.Search != "" && pagingInfo.Search != null)
                    {
                        bool IsDate = CommonService.IsDate(pagingInfo.Search);
                        if (IsDate != true)
                        {
                            IQueryable <Plan> Plansearch = uow.PlanRepo.GetAll().Where(e => (e.Title != null ? (e.Title.ToLower().Contains(pagingInfo.Search.ToLower())) : false) || e.Price.ToString().ToLower().Contains(pagingInfo.Search.ToLower()) || (e.Min.ToString() != null ? (e.Min.ToString().Contains(pagingInfo.Search.ToString())) : false) || e.Max.ToString().Contains(pagingInfo.Search) || (e.Tax.ToString() != null ? (e.Tax.ToString().ToLower().Contains(pagingInfo.Search.ToLower())) : false)).AsQueryable(); //|| e.IsEcoupon.ToString().Contains(pagingInfo.Search) //.OrderBy(e => e.Company);
                            Plansearch = PagingService.Sorting <Plan>(Plansearch, pagingInfo.SortBy, pagingInfo.Reverse);
                            Plansearch = Plansearch.Skip(skip).Take(take);

                            if (Plansearch != null)
                            {
                                foreach (var item in Plansearch)
                                {
                                    PlanDTO.Add(Transform.PlanToDTO(item));
                                }
                            }
                            return(PlanDTO.Skip(skip).Take(take).ToList());
                        }
                        else
                        {
                            ////date wise search
                            //DateTime date = Convert.ToDateTime(pagingInfo.Search);
                        }
                    }
                    else
                    {
                        foreach (var item in PlanDTOList)
                        {
                            PlanDTO.Add(item);
                        }
                        return(PlanDTO.Skip(skip).Take(take).ToList());
                    }
                }

                return(PlanDTOList);
            }
            catch (Exception)
            {
                throw;
            }
        }