Esempio n. 1
0
        public async Task <PagedList <ClientDetails> > GetAsync(PaginationWithFilter <ClientFilterModel> filter)
        {
            var count = await _dbContext.Person.CountAsync(x => x.IsActive);

            var rawData = _dbContext.Person.Where(x => x.IsActive);

            if (filter.Filter is { })
Esempio n. 2
0
        public async Task <PagedList <RecordModel> > GetRecordsAsync(PaginationWithFilter <RecordFilterModel> filter)
        {
            var filterParams = new
            {
                groupId = filter.Filter?.GroupId,
                date    = (filter.Filter?.Date ?? DateTime.Now).Date,
                name    = string.IsNullOrEmpty(filter.Filter?.Name) ? null : filter.Filter.Name
            };

            var rawData = await(
                from obj in _dbContext.Object
                join per in _dbContext.Person on obj.PersonKey equals per.Key
                join grp in _dbContext.PersonGroup on per.GroupId equals grp.Id
                where
                (obj.FrameDate >= filterParams.date && obj.FrameDate <= filterParams.date.AddDays(1)) &&
                (!filterParams.groupId.HasValue || per.GroupId == filterParams.groupId) &&
                (filterParams.name == null || (per.FirstName + per.LastName).Contains(filterParams.name))
                select new
            {
                Obj   = obj,
                Frame = obj.Frame,
                Grp   = grp,
                Per   = per
            }).ToListAsync();

            var count = rawData.GroupBy(x => x.Obj.PersonKey).Count();

            var data = rawData.GroupBy(x => x.Obj.PersonKey).Select(x =>
                                                                    new RecordModel(
                                                                        x.First().Per,
                                                                        x.OrderBy(t => t.Obj.FrameDate).First().Obj,
                                                                        _settings.Image)
                                                                    ).OrderBy(x => x.CreateDate).ToPagedList(filter).ToList();

            return(new PagedList <RecordModel>(count, data));
        }
Esempio n. 3
0
 public async Task <ActionResult <PagedList <RecordModel> > > GetRecordsAsync([FromQuery] PaginationWithFilter <RecordFilterModel> model) =>
 await _service.GetRecordsAsync(model);