Exemplo n.º 1
0
        public async Task <IEnumerable <CityResponse> > Handle(GetAllCitiesQuery request, CancellationToken cancellationToken)
        {
            var filter = _mapper.Map <GetAllCitiesFilter>(request.PropertiesRequestQueryString);
            var cities = await _citiesService.GetAllCitiesAsync(filter);

            return(_mapper.Map <IEnumerable <CityResponse> >(cities));
        }
        public async Task <ServiceResult <List <CityDto> > > Handle(GetAllCitiesQuery request, CancellationToken cancellationToken)
        {
            //Will be removed.
            await Task.Delay(5000, cancellationToken);

            List <CityDto> list = await _context.Cities
                                  .Include(x => x.Districts)
                                  .ThenInclude(c => c.Villages)
                                  .ProjectToType <CityDto>(_mapper.Config)
                                  .ToListAsync(cancellationToken);

            return(list.Count > 0 ? ServiceResult.Success(list) : ServiceResult.Failed <List <CityDto> >(ServiceError.NotFount));

            //TODO: If the Elastic Log see the canceled request remove below code block.
            //try
            //{
            //    await Task.Delay(5000, cancellationToken);

            //    List<CityDto> list = await _context.Cities
            //            .Include(x => x.Districts)
            //            .ThenInclude(c => c.Villages)
            //            .ProjectToType<CityDto>(_mapper.Config)
            //            .ToListAsync(cancellationToken);

            //    return list.Count > 0 ? ServiceResult.Success(list) : ServiceResult.Failed<List<CityDto>>(ServiceError.NotFount);
            //}
            //catch (TaskCanceledException)
            //{

            //}

            //return ServiceResult.Failed<List<CityDto>>(ServiceError.Canceled);
        }
Exemplo n.º 3
0
        public async Task <IList <CityListVm> > Handle(GetAllCitiesQuery request, CancellationToken cancellationToken)
        {
            var cities = await _cityRepository.GetAllAsync();

            var list = _mapper.Map <List <CityListVm> >(cities);

            return(list);
        }
Exemplo n.º 4
0
        public async Task <ServiceResult <List <CityDto> > > Handle(GetAllCitiesQuery request, CancellationToken cancellationToken)
        {
            List <CityDto> list = await _context.Cities
                                  .Include(x => x.Districts)
                                  .ThenInclude(c => c.Villages)
                                  .ProjectToType <CityDto>(_mapper.Config)
                                  .ToListAsync(cancellationToken);

            return(list.Count > 0 ? ServiceResult.Success(list) : ServiceResult.Failed <List <CityDto> >(ServiceError.NotFount));
        }
        public async Task ShouldReturnAllCities()
        {
            var query = new GetAllCitiesQuery();

            var result = await SendAsync(query);

            result.Should().NotBeNull();
            result.Succeeded.Should().BeTrue();
            result.Data.Count.Should().BeGreaterThan(0);
        }
Exemplo n.º 6
0
        public async Task <GenericPager <CityDto> > Handle(GetAllCitiesQuery request, CancellationToken cancellationToken)
        {
            var results = await _service.GetAllCities(request.FilterBy, request.ActualPage, request.RecordsByPage);

            return(results);
        }
Exemplo n.º 7
0
        public async Task <List <City> > Handle(GetAllCitiesQuery request, CancellationToken cancellationToken)
        {
            List <City> cities = await context.Cities.ToListAsync();

            return(cities);
        }
Exemplo n.º 8
0
 public async Task <IEnumerable <SelectedObjectDto> > GetCity([FromQuery] GetAllCitiesQuery model)
 {
     return(await SendRequestAsync(model));
 }
Exemplo n.º 9
0
        public async Task <IEnumerable <SelectedObjectDto> > Handle(GetAllCitiesQuery request, CancellationToken cancellationToken)
        {
            var data = _cityRepository.GetMany(r => r.IsActive).ToList();

            return(_mapper.Map <IEnumerable <SelectedObjectDto> >(data));
        }