コード例 #1
0
 public async Task <IActionResult> GetAll([FromQuery] FilterServiceOfPattientVM filter)
 => Ok(await _service.ServiceOfPattientService.GetAllWithPaginateAsync(filter));
コード例 #2
0
        public async Task <PaginationViewModel <ServiceOfPatient> > GetAllWithPaginateAsync(FilterServiceOfPattientVM filterEntity)
        {
            var result = GetAll();

            if (filterEntity.DentalBranchId != Guid.Empty)
            {
                result = result.Where(x => x.DentalBranchId == filterEntity.DentalBranchId);
            }

            var total = result.Count();
            var pages = total / filterEntity.QuantityByPage;

            return(new PaginationViewModel <ServiceOfPatient>
            {
                ActualPage = filterEntity.Page,
                Pages = pages,
                Total = total,
                Entities = await result.Skip((filterEntity.Page - 1) *filterEntity.QuantityByPage).Take(filterEntity.QuantityByPage)
                           .OrderByDescending(x => x.CreateAt).ToListAsync()
            });
        }