Beispiel #1
0
        private void FillFacilitiesQueryParams(FacilitiesFilterParams filterParams)
        {
            var predicate = PredicateBuilder.New <Facility>(true);

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

            filterParams.Expression = predicate;
        }
        public CollectionResult <FacilityDto> GetFacilitiesByParams(FacilitiesFilterParams filterParams)
        {
            var facilities = _unitOfWork.FacilityRepository.GetFacilitiesByParams(filterParams);

            var result = new CollectionResult <FacilityDto>
            {
                TotalCount = facilities.TotalCount,
                Collection = AutoMapper.Mapper.Map <IEnumerable <Facility>, List <FacilityDto> >(facilities.Collection)
            };

            return(result);
        }
Beispiel #3
0
        public CollectionResult <Facility> GetFacilitiesByParams(FacilitiesFilterParams filterParams)
        {
            var facilities = GetAllFacilities();

            FillFacilitiesQueryParams(filterParams);

            facilities = facilities.Where(filterParams.Expression);

            var totalCount = facilities.Count();

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

            var airTaxiResult = new CollectionResult <Facility>
            {
                Collection = result,
                TotalCount = totalCount
            };

            return(airTaxiResult);
        }
Beispiel #4
0
        public IActionResult GetFacilities([FromBody] FacilitiesFilterParams filterParams)
        {
            var facilities = _facilityService.GetFacilitiesByParams(filterParams);

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