public async Task <IEnumerable <CountryDto> > Handle(GetAllCountriesQuery request, CancellationToken cancellationToken)
 {
     return(await Task.FromResult(
                _mapper.Map <IEnumerable <CountryDto> >(_countryRepository.Get()
                                                        .OrderBy(x => x.Name)
                                                        .ToList())));
 }
Exemple #2
0
        public async Task <IActionResult> GetAllCountries()
        {
            var query  = new GetAllCountriesQuery();
            var result = await _mediator.Send(query);

            return(Ok(result));
        }
Exemple #3
0
        public async Task <List <CountryDto> > Handle(GetAllCountriesQuery request, CancellationToken cancellationToken)
        {
            var output = new List <CountryDto>();

            try
            {
                using (var client = new HttpClient())
                {
                    var url = _configuration.GetValue <string>("countryApi");

                    var result = await client.GetAsync(url);

                    var stringResult = await result.Content.ReadAsStringAsync();

                    output = JsonConvert.DeserializeObject <List <CountryDto> >(stringResult);
                }

                return(output);
            }
            catch (Exception ex)
            {
                _logger.LogError($"Unable to get country list from given Api. {ex.Message.ToString()}");
                throw ex;
            }
        }
Exemple #4
0
        public async Task <IEnumerable <CountryDto> > Handle(GetAllCountriesQuery request, CancellationToken cancellationToken)
        {
            var countries = await _context.Countries.ToListAsync();

            var result = _mapper.Map <IEnumerable <CountryDto> >(countries);

            return(result);
        }
Exemple #5
0
        public async Task <IList <CountryListVm> > Handle(GetAllCountriesQuery request, CancellationToken cancellationToken)
        {
            var countries = await _countryRepository.GetAllAsync();

            var list = _mapper.Map <List <CountryListVm> >(countries);

            return(list);
        }
Exemple #6
0
        public async Task GetAllShouldBeExecutedAsync()
        {
            var handler = new GetAllCountriesHandler(_countryRepositoryMock.Object, _mapperMock.Object);
            var request = new GetAllCountriesQuery();

            var countries = await handler.Handle(request, CancellationToken.None);

            Assert.NotNull(countries);
            _countryRepositoryMock.Verify(x => x.Get(), Times.Once);
        }
        public async Task <List <CountryDto> > Handle(GetAllCountriesQuery query, CancellationToken cancellationToken)
        {
            var connection = _sqlConnectionFactory.GetOpenConnection();

            return((await connection.QueryAsync <CountryDto>(
                        "SELECT " +
                        $"[Country].[Code] AS [{nameof(CountryDto.Code)}], " +
                        $"[Country].[Name] AS [{nameof(CountryDto.Name)}] " +
                        "FROM [meetings].[v_Countries] AS [Country]")).AsList());
        }
Exemple #8
0
        public async Task <IEnumerable <CountryDto> > Handle(GetAllCountriesQuery request, CancellationToken cancellationToken)
        {
            var countries = await _countryRepository.GetAll();

            return(countries.Select(x => new CountryDto
            {
                Id = x.Id,
                Name = x.Name,
                IsEnabled = x.IsEnabled,
                CreationDate = x.CreationDate,
                LastUpdate = x.LastUpdate
            }).ToList());
        }
Exemple #9
0
 public async Task <IEnumerable <Country> > Handle(GetAllCountriesQuery request, CancellationToken cancellationToken)
 {
     return(await _countryService.GetCountries());
 }
Exemple #10
0
        public async Task <GenericPager <CountryDto> > Handle(GetAllCountriesQuery request, CancellationToken cancellationToken)
        {
            var results = await _service.GetAllCountries(request.FilterBy, request.ActualPage, request.RecordsByPage);

            return(results);
        }
        public async Task <ActionResult> GET_ALL_COUNTRY()
        {
            var query = new GetAllCountriesQuery();

            return(Ok(await _mediator.Send(query)));
        }