public CollectionResult <AirTaxiDto> GetAirTaxiesByParams(TaxiesFilterParams filterParams) { var airTaxies = _unitOfWork.AirTaxiRepository.GetAirTaxiesByParams(filterParams); var result = new CollectionResult <AirTaxiDto> { TotalCount = airTaxies.TotalCount, Collection = AutoMapper.Mapper.Map <IEnumerable <AirTaxi>, List <AirTaxiDto> >(airTaxies.Collection) }; return(result); }
private void FillAirTaxiQueryParams(TaxiesFilterParams filterParams) { var predicate = PredicateBuilder.True <AirTaxi>(); if (!string.IsNullOrEmpty(filterParams.CustomerId)) { predicate = predicate.And(t => t.CustomerId == filterParams.CustomerId); } if (!string.IsNullOrEmpty(filterParams.Term)) { predicate = predicate.And(t => t.AirTaxiModel.Name.Contains(filterParams.Term)); } if (filterParams.SelectedTypeIds != null && filterParams.SelectedTypeIds.Any()) { predicate = predicate.And(t => filterParams.SelectedTypeIds.Any(id => id == t.AirTaxiModel.AirTaxiTypeId)); } if (filterParams.SelectedCompanyIds != null && filterParams.SelectedCompanyIds.Any()) { predicate = predicate.And(t => filterParams.SelectedCompanyIds.Any(id => id == t.AirTaxiModel.AirTaxiCompanyId)); } if (filterParams.SelectedModelIds != null && filterParams.SelectedModelIds.Any()) { predicate = predicate.And(t => filterParams.SelectedModelIds.Any(id => id == t.AirTaxiModelId)); } if (filterParams.Start.HasValue && filterParams.End.HasValue) { predicate = predicate.And(t => !t.Rents.Any() || !(t.Rents.Any(r => filterParams.Start.Value <= r.EndDate && filterParams.End.Value >= r.StartDate))); } if (filterParams.IsRentTaxi) { predicate = predicate.And(t => t.CustomerId != filterParams.CustomerId); } filterParams.Expression = predicate; }
public CollectionResult <AirTaxi> GetAirTaxiesByParams(TaxiesFilterParams filterParams) { var airTaxies = GetAllAirTaxies(); FillAirTaxiQueryParams(filterParams); airTaxies = airTaxies.Where(filterParams.Expression); var totalCount = airTaxies.Count(); var result = airTaxies .Skip(filterParams.Skip) .Take(filterParams.Take) .AsNoTracking() .ToList(); var airTaxiResult = new CollectionResult <AirTaxi> { Collection = result, TotalCount = totalCount }; return(airTaxiResult); }
public IActionResult GetAirTaxiesByParams([FromBody] TaxiesFilterParams filterParams) { var airTaxies = _airTaxiService.GetAirTaxiesByParams(filterParams); return(Json(JsonResultData.Success(airTaxies))); }