public async Task <ImmutableList <CountryModel> > Handle(GetCountries request,
                                                                 CancellationToken cancellationToken)
        {
            var countries = await _countryProvider.GetCountries();

            return(countries.ToImmutableList());
        }
Beispiel #2
0
 public TestableDashboardController(GetUserByClaimId userServices,
                                    GetCountries getCountries,
                                    IServiceLocator serviceLocator,
                                    IChartDataService chartDataService)
     : base(userServices, getCountries, serviceLocator, chartDataService)
 {
 }
Beispiel #3
0
        public static void Main(string[] args)
        {
            var host = CreateWebHostBuilder(args).Build();

            using (var scope = host.Services.CreateScope())
            {
                var services = scope.ServiceProvider;

                try
                {
                    var context = services.GetRequiredService <MovieContext>();
                    //context.Database.EnsureDeleted();
                    context.Database.EnsureCreated();
                    GetCountries.LoadCountries(context);
                    GetCountries.LoadLanguages(context);
                    SeedData.EnsurePopulated(context);
                } catch (Exception ex)
                {
                    var logger = services.GetRequiredService <ILogger <Program> >();
                    logger.LogError(ex, "An error occurred creating the DB.");
                }
            }

            host.Run();
        }
Beispiel #4
0
        public async Task <IEnumerable <CountryDto> > ExecuteAsync(GetCountries query)
        {
            try
            {
                var items = await _cache.AddOrGetExistingAsync("Countries",
                                                               async() =>
                {
                    var r = await _context.Locations
                            .Select(l => new CountryDto {
                        Code = l.CountryCode, Name = l.CountryName
                    })
                            .Distinct()
                            .OrderBy(l => l.Name)
                            .ToListAsync();

                    return(r);
                });

                return(items);
            }
            catch (Exception ex)
            {
                _loggerService.LogError(ex, ex.Message);
                return(null);
            }
        }
        public IActionResult Load(Int64?countryId, Int64?langId)
        {
            GetCountries operation = new GetCountries();

            operation.ID = countryId;
            if (langId.HasValue)
            {
                operation.LangID = langId;
            }
            else
            {
                operation.LangID = 1;
            }

            var result = operation.QueryAsync().Result;

            if (result is ValidationsOutput)
            {
                return(Ok(new ApiResult <List <ValidationItem> >()
                {
                    Data = ((ValidationsOutput)result).Errors
                }));
            }
            else
            {
                return(Ok((List <Country>)result));
            }
        }
Beispiel #6
0
 public object Get(GetCountries request)
 {
     return(Db.Select <Country>());
     //return new GetCountriesResponse
     //{
     //    Results = Db.Select<Country>()
     //};
 }
 public DashboardController(
     GetUserByClaimId getUser,
     GetCountries getCountries,
     IServiceLocator serviceLocator,
     IChartDataService chartDataService)
     : base(getUser, serviceLocator)
 {
     this.getCountries     = getCountries;
     this.chartDataService = chartDataService;
 }
        public void WhenGettingCountryListAndRepositoryReturnsNoRecords_ThenReturnsEmptyCollection()
        {
            var countryRepositoryMock = new Mock <ICountryRepository>();

            countryRepositoryMock.Setup(c => c.GetAll()).Returns(new List <Country>());
            var services = new GetCountries(countryRepositoryMock.Object);

            var countries = services.Execute();

            Assert.Empty(countries);
        }
Beispiel #9
0
 public ProfileController(
     UpdateUser updateUser,
     GetUserByClaimId getUser,
     GetCountries getCountries,
     IFormsAuthentication formsAuthentication)
     : base(getUser, null)
 {
     _updateUser          = updateUser;
     _getCountries        = getCountries;
     _formsAuthentication = formsAuthentication;
 }
        public async Task <ActionResult <GetCountriesResponse> > Get(CancellationToken cancellationToken)
        {
            var request = new GetCountries()
            {
                RequestId = this.GetRequestId(),
            };

            var response = await _mediator.Send(request, cancellationToken);

            return(Ok(response));
        }
Beispiel #11
0
        public async Task <List <CountryData> > HandleAsync(GetCountries query)
        {
            var result = await context.Countries.ToArrayAsync();

            var countryData = result.Select(c => new CountryData
            {
                Name = c.Name,
                Id   = c.Id
            }).OrderBy(c => c.Name).ToArray();

            return(countryData.ToList());
        }
Beispiel #12
0
        public JsonResult GetCountry(int value)
        {
            //String conexion = "data source=195.192.2.249;initial catalog=PLMClients 20160913;user id=sa;password=t0m$0nl@t1n@";
            String        conexion = System.Configuration.ConfigurationManager.AppSettings["Conexion"].ToString();
            SqlConnection cnn      = new SqlConnection(conexion);

            cnn.Open();

            List <GetCountries> Getcountries_Result = new List <GetCountries>();
            String consulta = "select c.CountryId,c.CountryName,c.ID,c.Active from Countries c order by c.CountryName";

            try
            {
                SqlCommand cmd = new SqlCommand(consulta, cnn);


                SqlDataReader read = cmd.ExecuteReader();


                if (read.HasRows == true)
                {
                    while (read.Read())
                    {
                        GetCountries GetCountriesinf = new GetCountries();
                        GetCountriesinf.CountryId   = Convert.ToInt32(read.GetValue(0));
                        GetCountriesinf.CountryName = read.GetValue(1).ToString();
                        GetCountriesinf.ID          = read.GetValue(2).ToString();
                        GetCountriesinf.Active      = Convert.ToBoolean(read.GetValue(3));


                        Getcountries_Result.Add(GetCountriesinf);
                    }
                }

                else
                {
                    string men = "No hay datos";
                }



                cnn.Close();
                return(Json(Getcountries_Result, JsonRequestBehavior.AllowGet));
            }
            catch (Exception e)
            {
                string message = e.Message;
                return(Json(true, JsonRequestBehavior.AllowGet));
            }
        }
        public void WhenGettingCountryList_ThenReturnsCountryNames()
        {
            var countryRepositoryMock = new Mock <ICountryRepository>();

            countryRepositoryMock.Setup(c => c.GetAll()).Returns(new List <Country>()
            {
                new Country()
            });
            var services = new GetCountries(countryRepositoryMock.Object);

            var countries = services.Execute();

            Assert.NotNull(countries);
            Assert.Equal(1, countries.Count);
        }
        public async Task <IEnumerable <Countries> > Handle(GetCountries request, CancellationToken cancellationToken)
        {
            var countriesList = new List <Countries>();

            using (var httpClient = new HttpClient())
            {
                using (var response = await httpClient.GetAsync("https://api.covid19api.com/countries"))
                {
                    string apiResponse = await response.Content.ReadAsStringAsync();

                    countriesList = JsonConvert.DeserializeObject <List <Countries> >(apiResponse);
                }
            }
            return(countriesList);
        }
Beispiel #15
0
        public async Task <IList <CountryData> > HandleAsync(GetCountries query)
        {
            var regionsOfUKOnly = query.UKRegionsOnly;
            var countries       = await context.Countries.ToArrayAsync();

            if (regionsOfUKOnly)
            {
                var ukcompetentauthories = await context.UKCompetentAuthorities.ToArrayAsync();

                var ukregions = countries.Join(ukcompetentauthories, c => c.Id, u => u.Country.Id,
                                               (c, u) => new CountryData {
                    Id = c.Id, Name = c.Name
                });
                return(ukregions.OrderBy(m => m.Name).ToList());
            }
            else
            {
                return(countries.Select(mapper.Map).OrderBy(m => m.Name).ToArray());
            }
        }
Beispiel #16
0
        /// <summary>
        /// Service method responsible for handling HTTP Get verb of GetCountries DTO request
        /// </summary>
        /// <param name="request">an object of GetCountries DTO type</param>
        /// <returns>an object of GetCountriesResponse DTO type</returns>
        public async Task <GetCountriesResponse> Get(GetCountries request)
        {
            var countryList = await _countryRepository.GetAllAsync();

            var countryResponses = new List <CountryResponse>();

            foreach (var item in countryList)
            {
                countryResponses.Add(new CountryResponse
                {
                    Mcc         = item.MobileCountryCode,
                    Cc          = item.CountryCode,
                    Name        = item.Name,
                    PricePerSMS = decimal.Parse(item.PricePerSMS.ToString().TrimEnd('0').TrimEnd('.'))
                });
            }

            return(new GetCountriesResponse {
                Result = countryResponses
            });
        }
Beispiel #17
0
        /// <summary>
        /// Gets the specified request.
        /// </summary>
        /// <param name="request">The request.</param>
        /// <returns>System.Object.</returns>
        public object Get(GetCountries request)
        {
            var result = CultureInfo.GetCultures(CultureTypes.SpecificCultures)

                         .Select(c => new RegionInfo(c.LCID))
                         .OrderBy(c => c.DisplayName)

                         // Try to eliminate dupes
                         .DistinctBy(c => c.TwoLetterISORegionName)

                         .Select(c => new CountryInfo
            {
                Name                     = c.Name,
                DisplayName              = c.DisplayName,
                TwoLetterISORegionName   = c.TwoLetterISORegionName,
                ThreeLetterISORegionName = c.ThreeLetterISORegionName
            })
                         .ToList();

            return(ToOptimizedResult(result));
        }
Beispiel #18
0
        /// <summary>
        /// Gets the specified request.
        /// </summary>
        /// <param name="request">The request.</param>
        /// <returns>System.Object.</returns>
        public object Get(GetCountries request)
        {
            var result = _localization.GetCountries().ToList();

            return(ToOptimizedResult(result));
        }
Beispiel #19
0
        public Task <List <Country> > GetCounties()
        {
            var obj = new GetCountries();

            return(obj.ExecuteReaderAsync());
        }
Beispiel #20
0
        /// <summary>
        /// Gets the specified request.
        /// </summary>
        /// <param name="request">The request.</param>
        /// <returns>System.Object.</returns>
        public async Task <object> Get(GetCountries request)
        {
            var result = await _localization.GetCountries();

            return(ToOptimizedResult(result));
        }
 public CountryListPresenter(GetCountries getCountries, CountryModelMapper countryModelMapper)
 {
     this.getCountries       = getCountries;
     this.countryModelMapper = countryModelMapper;
 }
 public GetCountriesController(GetCountries getCountries)
 {
     this.getCountries = getCountries;
 }