public static ApiRes <MainGraduateDto> GraduateLazyList(GraduateFilters filters, string sort, int page, int size)
        {
            ApiRes <MainGraduateDto> res = new ApiRes <MainGraduateDto>();

            sort                = sort == " ," || sort == " , " ? "" : sort;
            filters.active      = filters.active ?? new List <bool>();
            filters.gender      = filters.gender ?? new List <string>();
            filters.didGraduate = filters.didGraduate ?? new List <bool>();
            filters.hasDiploma  = filters.hasDiploma ?? new List <bool>();
            filters.isWork      = filters.isWork ?? new List <bool>();
            filters.expertise   = filters.expertise ?? new List <int>();
            filters.branch      = filters.branch ?? new List <int>();
            using (placementDepartmentDBEntities placementDepartmentDB = new placementDepartmentDBEntities())
            {
                res.items = placementDepartmentDB.Graduate
                            .Where(g =>
                                   (g.firstName + " " + g.lastName).IndexOf(filters.name) != -1 &&
                                   (!filters.active.Any() || filters.active.Contains(g.isActive)) &&
                                   (!filters.gender.Any() || filters.gender.Contains(g.gender)) &&
                                   (!filters.didGraduate.Any() || filters.didGraduate.Contains(g.didGraduate)) &&
                                   (!filters.hasDiploma.Any() || filters.hasDiploma.Contains(g.hasDiploma)) &&
                                   (!filters.isWork.Any() || filters.isWork.Contains(g.isWorkerInProfession)) &&
                                   (filters.period == 0 ||
                                    filters.period == 1 && g.dateOfRegistration == DateTime.Now ||
                                    filters.period == 2 && g.dateOfRegistration >= filters.startDate && g.dateOfRegistration <= filters.endDate) &&
                                   (!filters.expertise.Any() || filters.expertise.Contains(g.expertiseId)) &&
                                   (!filters.branch.Any() || filters.branch.Contains(g.branchId))
                                   )
                            .OrderBy(sort + "dateOfRegistration desc")
                            .Skip(page * size)
                            .Take(size)
                            .Select(g => new MainGraduateDto()
                {
                    Id            = g.Id,
                    Name          = g.firstName + " " + g.lastName,
                    branchName    = g.Branch.name,
                    expertiseName = g.Expertise.name,
                    endYear       = g.endYear,
                    isActive      = g.isActive
                }).ToList();
                res.totalCount = placementDepartmentDB.Graduate.Where(g =>
                                                                      (g.firstName + " " + g.lastName).IndexOf(filters.name) != -1 &&
                                                                      (!filters.active.Any() || filters.active.Contains(g.isActive)) &&
                                                                      (!filters.gender.Any() || filters.gender.Contains(g.gender)) &&
                                                                      (!filters.didGraduate.Any() || filters.didGraduate.Contains(g.didGraduate)) &&
                                                                      (!filters.hasDiploma.Any() || filters.hasDiploma.Contains(g.hasDiploma)) &&
                                                                      (!filters.isWork.Any() || filters.isWork.Contains(g.isWorkerInProfession)) &&
                                                                      (filters.period == 0 ||
                                                                       filters.period == 1 && g.dateOfRegistration == DateTime.Now ||
                                                                       filters.period == 2 && g.dateOfRegistration >= filters.startDate && g.dateOfRegistration <= filters.endDate) &&
                                                                      (!filters.expertise.Any() || filters.expertise.Contains(g.expertiseId)) &&
                                                                      (!filters.branch.Any() || filters.branch.Contains(g.branchId))
                                                                      ).Count();
                return(res);
            }
        }
 public ApiRes <MainGraduateDto> Get(int page, int size, string sort, [FromUri] GraduateFilters filters)
 {
     return(GraduateDtoManager.GraduateDtoLazyList(filters, sort, page, size));
 }
Ejemplo n.º 3
0
 public static ApiRes <MainGraduateDto> GraduateDtoLazyList(GraduateFilters filters, string sort, int page, int size)
 {
     return(GraduateManager.GraduateLazyList(filters, sort, page, size));
 }