コード例 #1
0
 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())));
 }
コード例 #2
0
        public async Task <IActionResult> GetAllCountries()
        {
            var query  = new GetAllCountriesQuery();
            var result = await _mediator.Send(query);

            return(Ok(result));
        }
コード例 #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;
            }
        }
コード例 #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);
        }
コード例 #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);
        }
コード例 #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());
        }
コード例 #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());
        }
コード例 #9
0
 public async Task <IEnumerable <Country> > Handle(GetAllCountriesQuery request, CancellationToken cancellationToken)
 {
     return(await _countryService.GetCountries());
 }
コード例 #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);
        }
コード例 #11
0
        public async Task <ActionResult> GET_ALL_COUNTRY()
        {
            var query = new GetAllCountriesQuery();

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