Пример #1
0
        private void FillResidentContactQueryParams(ResidentContactsFilterParams filterParams)
        {
            var predicate = PredicateBuilder.New <ResidentContact>(true);

            if (!string.IsNullOrEmpty(filterParams.UserId))
            {
                predicate = predicate.And(t => t.UserId == filterParams.UserId);
            }

            if (filterParams.FacilityId.HasValue)
            {
                predicate = predicate.And(t => t.Resident.Department.FacilityId == filterParams.FacilityId);
            }

            filterParams.Expression = predicate;
        }
Пример #2
0
        public CollectionResult <ResidentContact> GetResidentContactsByParams(ResidentContactsFilterParams filterParams)
        {
            var residents = GetAllResidentContacts();

            FillResidentContactQueryParams(filterParams);

            residents = residents.Where(filterParams.Expression);

            var totalCount = residents.Count();

            var result = residents
                         .Skip(filterParams.Skip)
                         .Take(filterParams.Take)
                         .AsNoTracking()
                         .ToList();

            var residentResult = new CollectionResult <ResidentContact>
            {
                Collection = result,
                TotalCount = totalCount
            };

            return(residentResult);
        }
        public IActionResult GetResidentContacts([FromBody] ResidentContactsFilterParams filterParams)
        {
            var residents = _residentContactService.GetResidentContactsByParams(filterParams);

            return(Json(JsonResultData.Success(residents)));
        }