public ActionResult Index(GetFillLotsInput input) { return(base.View()); }
public async Task <PagedResultOutput <FillLotListDto> > GetFillLots(GetFillLotsInput input) { //FillLotAppService.<>c__DisplayClass8_1 variable = null; //FillLotAppService.<>c__DisplayClass8_0 variable1 = null; //FillLotAppService.<>c__DisplayClass8_2 variable2 = null; int fillLotId; IQueryable <FillLot> all = _fillLotRepository.GetAll(); var fillLots = all.Where(p => p.TenantId == AbpSession.TenantId && p.Id == 0); // Really? var listAsync = await fillLots.Select(s => new { FillLotId = s.Id }).ToListAsync(); var collection = listAsync; List <long> foundFillLotIdsFromInputFilter = ( from s in collection select s.FillLotId).ToList(); bool foundUsingIdFilter = false; if (input.Filter.ToLower().StartsWith("id:")) { try { string lower = input.Filter.ToLower(); char[] chrArray = new char[] { ':' }; int.TryParse(lower.Split(chrArray)[1].ToString(), out fillLotId); IQueryable <FillLot> all1 = _fillLotRepository.GetAll(); var fillLots1 = all1.Where(p => p.TenantId == AbpSession.TenantId && p.Id == fillLotId); var listAsync1 = await fillLots1.Select(s => new { FillLotId = s.Id }).ToListAsync(); foundUsingIdFilter = true; foundFillLotIdsFromInputFilter = foundFillLotIdsFromInputFilter.Union( from s in listAsync1 select s.FillLotId).ToList(); } catch (Exception) { } } if (!foundUsingIdFilter) { IQueryable <FillLot> all2 = _fillLotRepository.GetAll(); var fillLots2 = all2.WhereIf(!input.Filter.IsNullOrEmpty(), p => p.Label.Contains(input.Filter) || p.ShortLabel.Contains(input.Filter) || p.Description.Contains(input.Filter)); var listAsync2 = await fillLots2.Select(s => new { FillLotId = s.Id }).ToListAsync(); foundFillLotIdsFromInputFilter = foundFillLotIdsFromInputFilter.Union( from s in listAsync2 select s.FillLotId).ToList(); } IQueryable <FillLot> all3 = this._fillLotRepository.GetAll(); var fillLots3 = all3.Where(m => foundFillLotIdsFromInputFilter.Contains(m.Id)); int resultCount = await fillLots3.CountAsync(); List <FillLot> orderedResult = await fillLots3.OrderBy(input.Sorting, new object[0]).PageBy(input).ToListAsync(); List <FillLotListDto> fillLotListDtos = orderedResult.MapTo <List <FillLotListDto> >(); foreach (FillLotListDto countryDto in fillLotListDtos) { FillLotListDto fillLotListDto = countryDto; int tankTotal = await _fillLotTankRepository.CountAsync(m => m.FillLotId == countryDto.Id); fillLotListDto.TankTotal = tankTotal; fillLotListDto = null; if (countryDto.AddressId > 0) { Address async = await _addressRepository.GetAsync(countryDto.AddressId); countryDto.Address = async.MapTo <AddressDto>(); if (countryDto.Address.CountryId <= 0) { countryDto.Address.Country = new CountryDto(); } else { Country country = await this._countryRepository.GetAsync(countryDto.Address.CountryId); countryDto.Address.Country = country.MapTo <CountryDto>(); } if (!countryDto.Address.CountryRegionId.HasValue) { countryDto.Address.CountryRegion = new CountryRegionDto(); } else { IRepository <CountryRegion> repository1 = this._countryRegionRepository; int? countryRegionId = countryDto.Address.CountryRegionId; CountryRegion countryRegion = await repository1.GetAsync(countryRegionId.Value); countryDto.Address.CountryRegion = countryRegion.MapTo <CountryRegionDto>(); } } } return(new PagedResultOutput <FillLotListDto>(resultCount, fillLotListDtos)); }