public virtual async Task <GetAllCertificateOutput> GetWithFilter(GetAllCertificateWithFilterInput filterInput)
        {
            var emptyStr = new Func <string, bool>(string.IsNullOrEmpty);

            var query = _certificateManager.Certificates.Include(c => c.File)
                        .WhereIf(!emptyStr(filterInput.Name), c => c.Name.Contains(filterInput.Name))
                        .WhereIf(filterInput.Levels != null && filterInput.Levels.Any(),
                                 c => filterInput.Levels.Contains(c.Level))
                        .Where(c
                               => c.AwardDate >= (filterInput.TimeStart ?? DateTime.MinValue) &&
                               c.AwardDate <= (filterInput.TimeEnd ?? DateTime.MaxValue));

            return(await Task.Run(() => MakePage(query, filterInput.SkipCount, filterInput.MaxResultCount)));
        }
示例#2
0
        public async Task <PartialViewResult> GetAllCertificateWithFilter(string name, DateTime timeStart, DateTime timeEnd, List <CertificateLevel> levels, int maxResultCount, int skipCount)
        {
            var filter = new GetAllCertificateWithFilterInput
            {
                Name           = name,
                TimeStart      = timeStart,
                TimeEnd        = timeEnd,
                Levels         = levels,
                MaxResultCount = maxResultCount,
                SkipCount      = skipCount,
            };

            return(PartialView("Certificate/_CertificateTable", new GetAllCertificateViewModel
            {
                Certificates = await _certificateAppService.GetWithFilter(filter),
                CurrentFilter = filter
            }));
        }