Esempio n. 1
0
 public IQueryable <Career> GetFilteredQuery(IQueryable <Career> all, CustomCareerInput input)
 {
     if (input.AcademicUnitId != 0)
     {
         all = all.Where(a => a.AcademicUnitId == input.AcademicUnitId);
     }
     all = all.WhereIf(!string.IsNullOrEmpty(input.search), a => a.Name.Contains(input.search));
     return(all);
 }
Esempio n. 2
0
        public IQueryable <Career> GetOrderedQuery(IQueryable <Career> all, CustomCareerInput input)
        {
            switch (input.sort)
            {
            case "name":
                return(input.order == "desc" ? all.OrderByDescending(a => a.Name) : all.OrderBy(a => a.Name));

            default:
                return(input.order == "desc" ? all.OrderByDescending(a => a.CreationTime) : all.OrderBy(a => a.CreationTime));
            }
        }
Esempio n. 3
0
        public PagedResultDto <CareerDto> GetAll(CustomCareerInput input)
        {
            var all = _repository.GetAll();

            var filtered = GetFilteredQuery(all, input);

            var ordered = GetOrderedQuery(filtered, input);

            var paged = ordered.Skip(input.offset).Take(input.limit).ToList();

            return(new PagedResultDto <CareerDto>(filtered.Count(), paged.Select(a => a.MapTo <CareerDto>()).ToList()));
        }