public PagedResult <CustomerModel> Get(CommonRequest request)
        {
            var query  = _dbContext.Customers.AsNoTracking().Where(a => !a.IsDelete).AsQueryable();
            var result = PagingExtensions.GetPaged <Domain.Entities.Customer, CustomerModel>(query, request.PageIndex, request.PageSize);

            return(this.ComposeResponse(result));
        }
Example #2
0
        public PartialViewResult search_by_state(int?page, string state)
        {
            currentPageIndex = page.HasValue ? page.Value - 1 : 0;
            var ClientBoosters = db.BusinessInfoes.Where(b => b.State.Contains(state) && b.ApprovedStatus == "A" && b.NotifyStatus == 1 && b.isServiceBooster == "Yes")
                                 .OrderByDescending(b => b.Recommended_Status)
                                 .ThenByDescending(b => b.VerifiedStatus);

            return(PartialView("_ClientBoosterList", PagingExtensions.ToPagedList(ClientBoosters, currentPageIndex, DefaultPageSize)));
        }
Example #3
0
        [AllowAnonymous] //Service Boosters Registered and approved businesses
        public ActionResult Client_Booster_List(int?page)
        {
            currentPageIndex = page.HasValue ? page.Value - 1 : 0;
            var ClientBoosters = db.BusinessInfoes.Where(cb => cb.isServiceBooster == "Yes" && cb.ApprovedStatus == "A" && cb.NotifyStatus == 1)
                                 .OrderByDescending(b => b.Recommended_Status)
                                 .ThenByDescending(b => b.VerifiedStatus);

            return(View(PagingExtensions.ToPagedList(ClientBoosters, currentPageIndex, DefaultPageSize)));
        }
Example #4
0
        public ActionResult Players(int sortBy, int pageNumber)
        {
            int count   = 0;
            var db      = new PlayerRepository();
            var players = db.SortPlayerBy(sortBy, pageNumber, 10, out count);

            ViewBag.PageCount       = PagingExtensions.PageCount(count, 10);
            ViewBag.PageNumber      = pageNumber;
            ViewBag.SortBySelection = sortBy;
            return(View(players));
        }
        /// <summary>
        /// Converts a query to an instance of PagedQueryResult, executing the query twice,
        /// once to get the total count and again to get the results.
        /// </summary>
        public static async Task <PagedQueryResult <T> > ToPagedResultAsync <T>(this IQueryable <T> source, IPageableQuery query)
        {
            Condition.Requires(source).IsNotNull();

            var result = new PagedQueryResult <T>();

            result.TotalItems = await source.CountAsync();

            result.Items = await source.Page(query).ToArrayAsync();

            PagingExtensions.MapPagingData <T>(query, result);

            return(result);
        }
Example #6
0
        public ActionResult Players()
        {
            var pageStart      = 1;
            var sortStartValue = 1;
            int count          = 0;
            var db             = new PlayerRepository();
            var players        = db.GetAllPlayers(pageStart, 10, out count);
            var pageCount      = PagingExtensions.PageCount(count, 10);

            ViewBag.PageCount       = pageCount;
            ViewBag.PageNumber      = pageStart;
            ViewBag.SortBySelection = sortStartValue;
            return(View(players));
        }
Example #7
0
        /// <summary>
        /// Converts a query to an instance of PagedQueryResult, executing the query twice,
        /// once to get the total count and again to get the results.
        /// </summary>
        public static async Task <PagedQueryResult <T> > ToPagedResultAsync <T>(this IQueryable <T> source, IPageableQuery query)
        {
            if (source == null)
            {
                throw new ArgumentNullException(nameof(source));
            }

            var result = new PagedQueryResult <T>();

            result.TotalItems = await source.CountAsync();

            result.Items = await source.Page(query).ToArrayAsync();

            PagingExtensions.MapPagingData <T>(query, result);

            return(result);
        }
Example #8
0
 public IQueryable <T> All(int page, int pageSize)
 {
     return(PagingExtensions.Page(Query, page, pageSize));
 }
Example #9
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        //public async Task<List<Employee>> GetAllEmployees()
        //{
        //    return await _context.Employee.Include(e => e.EmployeeRoles).ThenInclude(e => e.Role).ToListAsync();
        //}


        public List <Employee> GetAllEmployees(SearchSortModel search)
        {
            var query = _context.Employee.Include(e => e.EmployeeRoles).ThenInclude(e => e.Role).AsQueryable();


            if (!string.IsNullOrEmpty(search.SearchString) && search.PropertyName.ToLower() == "employeename")
            {
                query = query.Where(t => t.Name.ToLower().Contains(search.SearchString));
            }
            if (!string.IsNullOrEmpty(search.SearchString) && search.PropertyName.ToLower() == "email")
            {
                query = query.Where(t => t.Email.ToLower().Contains(search.SearchString));
            }
            if (!string.IsNullOrEmpty(search.SearchString) && search.PropertyName.ToLower() == "role")
            {
                query = query.Where(t => t.EmployeeRoles.Any(r => r.RoleId == Convert.ToInt32(search.SearchString)));
            }

            if (search.userId != 0 && search.roleId != 0)
            {
                if (search.roleId == 1)
                {
                    query = query.Where(t => t.Id != search.userId && (
                                            t.EmployeeRoles.Any(role => role.RoleId == 2 || role.RoleId == 3)));
                }
                if (search.roleId == 2)
                {
                    query = query.Where(t => t.Id != search.userId && (
                                            t.EmployeeRoles.Any(role => role.RoleId == 3)));
                }
            }

            search.TotalRecords = query.Count();

            switch (search.SortDirection.ToString().ToLower())
            {
            case "asc":
                if (search.SortColumn.ToLower() == "employeecode")
                {
                    query = query.OrderBy(dec => dec.EmployeeCode);
                }
                else if (search.SortColumn.ToLower() == "employeename")
                {
                    query = query.OrderBy(dec => dec.Name);
                }
                else
                {
                    query = query.OrderBy(dec => dec.EmployeeCode);
                }
                break;

            default:
                if (search.SortColumn.ToLower() == "employeecode")
                {
                    query = query.OrderByDescending(dec => dec.EmployeeCode);
                }
                else if (search.SortColumn.ToLower() == "employeename")
                {
                    query = query.OrderByDescending(dec => dec.Name);
                }
                else
                {
                    query = query.OrderByDescending(dec => dec.EmployeeCode);
                }
                break;
            }

            query = PagingExtensions.Page(query, search.Page, search.PageSize);

            var data = query
                       .Select(user => new Employee
            {
                Id           = user.Id,
                EmployeeCode = user.EmployeeCode,
                CurrentResidentialAddress = user.CurrentResidentialAddress,
                Email    = user.Email,
                Name     = user.Name,
                Password = user.Password,
                PermanentResidentialAddress = user.PermanentResidentialAddress,
                EmployeeRoles = user.EmployeeRoles,
                Status        = user.Status
            })
                       .ToList();

            return(data);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="search"></param>
        /// <returns></returns>
        public List <CovidHealthTrack> GetCovidDeclarations(SearchSortModel search)
        {
            var query = _context.CovidHealthTrack.Include(h => h.Employee).ThenInclude(e => e.EmployeeRoles).Include("Location");

            if (!string.IsNullOrEmpty(search.SearchString) && search.PropertyName.ToLower() == "employeename")
            {
                query = query.Where(t => t.Employee.Name.ToLower().Contains(search.SearchString));
            }
            if (!string.IsNullOrEmpty(search.SearchString) && search.PropertyName.ToLower() == "employeeid")
            {
                query = query.Where(t => t.Employee.EmployeeCode == Convert.ToInt32(search.SearchString));
            }
            if (!string.IsNullOrEmpty(search.SearchString) && search.PropertyName.ToLower() == "date")
            {
                query = query.Where(t => t.CreatedDate.Date == Convert.ToDateTime(search.SearchString).Date);
            }
            if (search.userId != 0 && search.roleId != 0)
            {
                if (search.roleId == 1)
                {
                    query = query.Where(t => t.EmployeeId != search.userId && (
                                            t.Employee.EmployeeRoles.Any(role => role.RoleId == 2 || role.RoleId == 3)));
                }
            }

            search.TotalRecords = query.Count();

            switch (search.SortDirection.ToString().ToLower())
            {
            case "asc":
                if (search.SortColumn == "id")
                {
                    query = query.OrderBy(dec => dec.Id);
                }
                else if (search.SortColumn == "employeename")
                {
                    query = query.OrderBy(dec => dec.Employee.Name);
                }
                else
                {
                    query = query.OrderBy(dec => dec.CreatedDate);
                }
                break;

            default:
                if (search.SortColumn == "id")
                {
                    query = query.OrderByDescending(dec => dec.Id);
                }
                else if (search.SortColumn == "employeename")
                {
                    query = query.OrderByDescending(dec => dec.Employee.Name);
                }
                else
                {
                    query = query.OrderByDescending(dec => dec.CreatedDate);
                }
                break;
            }

            query = PagingExtensions.Page(query, search.Page, search.PageSize);

            var data = query
                       .Select(declaration => new CovidHealthTrack
            {
                Id = declaration.Id,
                CovidConfirmationDate  = declaration.CovidConfirmationDate,
                DateOfSymptoms         = declaration.DateOfSymptoms,
                FamilyMembersCount     = declaration.FamilyMembersCount,
                HospitalizationNeed    = declaration.HospitalizationNeed,
                OfficeLastDay          = declaration.OfficeLastDay,
                OthersInfectedInFamily = declaration.OthersInfectedInFamily,
                Status      = declaration.Status,
                LocationId  = declaration.LocationId,
                CreatedDate = declaration.CreatedDate,
                EmployeeId  = declaration.EmployeeId,
                Employee    = declaration.Employee
            })
                       .ToList();

            return(data);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="search"></param>
        /// <returns></returns>
        public List <HealthTrack> GetDeclarationsByUserId(SearchSortModel search)
        {
            var query = _context.HealthTrack.Include(h => h.Employee).Include("Location").Include("Zone");

            if (!string.IsNullOrEmpty(search.SearchString) && search.PropertyName.ToLower() == "date")
            {
                query = query.Where(t => t.CreatedDate.Date == Convert.ToDateTime(search.SearchString).Date);
            }
            if (search.userId != 0)
            {
                query = query.Where(t => t.EmployeeId == search.userId);
            }

            search.TotalRecords = query.Count();

            switch (search.SortDirection.ToString().ToLower())
            {
            case "asc":
                if (search.SortColumn == "id")
                {
                    query = query.OrderBy(dec => dec.Id);
                }
                else if (search.SortColumn == "employeename")
                {
                    query = query.OrderBy(dec => dec.Employee.Name);
                }
                else
                {
                    query = query.OrderBy(dec => dec.CreatedDate);
                }
                break;

            default:
                if (search.SortColumn == "id")
                {
                    query = query.OrderByDescending(dec => dec.Id);
                }
                else if (search.SortColumn == "employeename")
                {
                    query = query.OrderByDescending(dec => dec.Employee.Name);
                }
                else
                {
                    query = query.OrderByDescending(dec => dec.CreatedDate);
                }
                break;
            }

            query = PagingExtensions.Page(query, search.Page, search.PageSize);

            var data = query
                       .Select(declaration => new HealthTrack
            {
                Id = declaration.Id,
                ResidentialAddress         = declaration.ResidentialAddress,
                PreExistHealthIssue        = declaration.PreExistHealthIssue,
                ContactWithCovidPeople     = declaration.ContactWithCovidPeople,
                TravelOustSideInLast15Days = declaration.TravelOustSideInLast15Days,
                RequestNumber = declaration.RequestNumber,
                LocationId    = declaration.LocationId,
                CreatedDate   = declaration.CreatedDate,
                ZoneId        = declaration.ZoneId,
                EmployeeId    = declaration.EmployeeId,
                Employee      = declaration.Employee
            })
                       .ToList();

            return(data);
        }
Example #12
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public List <ComeToOfficeRequest> GetRequestsList(SearchSortModel search)
        {
            // Employe can have only 1 request "Active" at a time
            // when entered office it is set to "finished"

            //return (roleId == 1 ? await _context.ComeToOfficeRequest.Include(r => r.Employee).ThenInclude(r => r.EmployeeRoles).
            //      Where(x => x.Status == EntityStatus.Active && x.EmployeeId != userId && (
            //      x.Employee.EmployeeRoles.Any(role => role.RoleId == 2 || role.RoleId == 3))).ToListAsync()
            //      : await _context.ComeToOfficeRequest.Include(r => r.Employee).ThenInclude(r => r.EmployeeRoles).
            //      Where(x => x.Status == EntityStatus.Active && x.EmployeeId != userId).ToListAsync());


            var query = _context.ComeToOfficeRequest.Include(r => r.Employee).ThenInclude(e => e.EmployeeRoles).AsQueryable();

            if (!string.IsNullOrEmpty(search.SearchString) && search.PropertyName.ToLower() == "requestnumber")
            {
                query = query.Where(t => t.RequestNumber.ToLower().Contains(search.SearchString));
            }
            if (!string.IsNullOrEmpty(search.SearchString) && search.PropertyName.ToLower() == "employeename")
            {
                query = query.Where(t => t.Employee.Name.ToLower().Contains(search.SearchString));
            }
            if (!string.IsNullOrEmpty(search.SearchString) && search.PropertyName.ToLower() == "employeeid")
            {
                query = query.Where(t => t.Employee.EmployeeCode == Convert.ToInt32(search.SearchString));
            }
            if (!string.IsNullOrEmpty(search.SearchString) && search.PropertyName.ToLower() == "daterange")
            {
                string[] dates = search.SearchString.Split("(to)");
                query = query.Where(t => t.FromDate.Date >= Convert.ToDateTime(dates[0]).Date&& (t.ToDate.Date == Convert.ToDateTime(dates[1]).Date || (t.FromDate.Date < Convert.ToDateTime(dates[1]).Date&& t.ToDate.Date < Convert.ToDateTime(dates[1]).Date)));
            }
            if (!string.IsNullOrEmpty(search.SearchString) && search.PropertyName.ToLower() == "status")
            {
                if (search.SearchString.ToLower() == "pending")
                {
                    query = query.Where(t => t.IsApproved == false && t.IsDeclined == false && t.Status == EntityStatus.Active);
                }
                else if (search.SearchString.ToLower() == "approved")
                {
                    query = query.Where(t => t.IsApproved == true && t.IsDeclined == false && t.Status == EntityStatus.Active);
                }
                else if (search.SearchString.ToLower() == "declined")
                {
                    query = query.Where(t => t.IsApproved == false && t.IsDeclined == true && t.Status == EntityStatus.Active);
                }
            }

            if (search.userId != 0 && search.roleId != 0)
            {
                if (search.roleId == 1)
                {
                    query = query.Where(t => t.EmployeeId != search.userId && (
                                            t.Employee.EmployeeRoles.Any(role => role.RoleId == 2 || role.RoleId == 3)));
                }
            }

            search.TotalRecords = query.Count();

            switch (search.SortDirection.ToString().ToLower())
            {
            case "asc":
                if (search.SortColumn == "id")
                {
                    query = query.OrderBy(dec => dec.Id);
                }
                else if (search.SortColumn == "employeename")
                {
                    query = query.OrderBy(dec => dec.Employee.Name);
                }
                else if (search.SortColumn.ToLower() == "fromdate")
                {
                    query = query.OrderBy(dec => dec.FromDate);
                }
                else if (search.SortColumn == "todate")
                {
                    query = query.OrderBy(dec => dec.ToDate);
                }
                else
                {
                    query = query.OrderBy(dec => dec.CreatedDate);
                }
                break;

            default:
                if (search.SortColumn == "id")
                {
                    query = query.OrderByDescending(dec => dec.Id);
                }
                else if (search.SortColumn == "employeename")
                {
                    query = query.OrderByDescending(dec => dec.Employee.Name);
                }
                else if (search.SortColumn.ToLower() == "fromdate")
                {
                    query = query.OrderByDescending(dec => dec.FromDate);
                }
                else if (search.SortColumn == "todate")
                {
                    query = query.OrderByDescending(dec => dec.ToDate);
                }
                else
                {
                    query = query.OrderByDescending(dec => dec.CreatedDate);
                }
                break;
            }

            query = PagingExtensions.Page(query, search.Page, search.PageSize);

            var data = query
                       .Select(request => new ComeToOfficeRequest
            {
                Id            = request.Id,
                CreatedBy     = request.CreatedBy,
                FromDate      = request.FromDate,
                HRComments    = request.HRComments,
                IsApproved    = request.IsApproved,
                IsDeclined    = request.IsDeclined,
                ModifiedBy    = request.ModifiedBy,
                CreatedDate   = request.CreatedDate,
                ModifiedDate  = request.ModifiedDate,
                EmployeeId    = request.EmployeeId,
                RequestNumber = request.RequestNumber,
                Status        = request.Status,
                ToDate        = request.ToDate,
                Employee      = request.Employee
            })
                       .ToList();

            return(data);
        }
Example #13
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public List <ComeToOfficeRequest> GetRequestsListByUserId(SearchSortModel search)
        {
            //return await _context.ComeToOfficeRequest.Include("Employee").Where(x => x.EmployeeId == userId).ToListAsync();

            var query = _context.ComeToOfficeRequest.Include("Employee");

            if (!string.IsNullOrEmpty(search.SearchString) && search.PropertyName.ToLower() == "requestnumber")
            {
                query = query.Where(t => t.RequestNumber.ToLower().Contains(search.SearchString));
            }

            if (!string.IsNullOrEmpty(search.SearchString) && search.PropertyName.ToLower() == "daterange")
            {
                string[] dates = search.SearchString.Split("(to)");
                query = query.Where(t => t.FromDate.Date >= Convert.ToDateTime(dates[0]).Date&& (t.ToDate.Date == Convert.ToDateTime(dates[1]).Date || (t.FromDate.Date < Convert.ToDateTime(dates[1]).Date&& t.ToDate.Date < Convert.ToDateTime(dates[1]).Date)));
            }
            if (!string.IsNullOrEmpty(search.SearchString) && search.PropertyName.ToLower() == "status")
            {
                if (search.SearchString.ToLower() == "pending")
                {
                    query = query.Where(t => t.IsApproved == false && t.IsDeclined == false && t.Status == EntityStatus.Active);
                }
                else if (search.SearchString.ToLower() == "approved")
                {
                    query = query.Where(t => t.IsApproved == true && t.IsDeclined == false && t.Status == EntityStatus.Active);
                }
                else if (search.SearchString.ToLower() == "declined")
                {
                    query = query.Where(t => t.IsApproved == false && t.IsDeclined == true && t.Status == EntityStatus.Active);
                }
            }

            if (search.userId != 0)
            {
                query = query.Where(t => t.EmployeeId == search.userId);
            }

            search.TotalRecords = query.Count();

            switch (search.SortDirection.ToString().ToLower())
            {
            case "asc":
                if (search.SortColumn == "id")
                {
                    query = query.OrderBy(dec => dec.Id);
                }
                else if (search.SortColumn.ToLower() == "fromdate")
                {
                    query = query.OrderBy(dec => dec.FromDate);
                }
                else if (search.SortColumn == "todate")
                {
                    query = query.OrderBy(dec => dec.ToDate);
                }
                else
                {
                    query = query.OrderBy(dec => dec.CreatedDate);
                }
                break;

            default:
                if (search.SortColumn == "id")
                {
                    query = query.OrderByDescending(dec => dec.Id);
                }
                else if (search.SortColumn.ToLower() == "fromdate")
                {
                    query = query.OrderByDescending(dec => dec.FromDate);
                }
                else if (search.SortColumn == "todate")
                {
                    query = query.OrderByDescending(dec => dec.ToDate);
                }
                else
                {
                    query = query.OrderByDescending(dec => dec.CreatedDate);
                }
                break;
            }

            query = PagingExtensions.Page(query, search.Page, search.PageSize);

            var data = query
                       .Select(request => new ComeToOfficeRequest
            {
                Id            = request.Id,
                CreatedBy     = request.CreatedBy,
                FromDate      = request.FromDate,
                HRComments    = request.HRComments,
                IsApproved    = request.IsApproved,
                IsDeclined    = request.IsDeclined,
                ModifiedBy    = request.ModifiedBy,
                CreatedDate   = request.CreatedDate,
                ModifiedDate  = request.ModifiedDate,
                EmployeeId    = request.EmployeeId,
                RequestNumber = request.RequestNumber,
                Status        = request.Status,
                ToDate        = request.ToDate,
                Employee      = request.Employee
            })
                       .ToList();

            return(data);
        }
Example #14
0
 public IQueryable <T> Page(IQueryable <T> source, int page, int pageSize)
 {
     return(PagingExtensions.Page(source, page, pageSize));
 }
Example #15
0
 public IQueryable <T> All <T>(int page, int pageSize) where T : class, new()
 {
     return(PagingExtensions.Page(All <T>(), page, pageSize));
 }
Example #16
0
 public IQueryable <T> All <T>(System.Linq.Expressions.Expression <Func <T, bool> > expression, int page, int pageSize) where T : class, new()
 {
     return(PagingExtensions.Page(All <T>(expression), page, pageSize));
 }
Example #17
0
        public IQueryable <TEntity> All <TEntity>(int page, int pageSize) where TEntity : class, new()
        {
            var collection = GetCollection <TEntity>();

            return(PagingExtensions.Page(collection.AsQueryable(), page, pageSize));
        }