Exemplo n.º 1
0
        public override void LoadSelectLists(List <int> embargoedCountries, Company company)
        {
            Countries.Add(new SelectListItem()
            {
                Text     = "No public offer",
                Value    = "",
                Selected = true
            });

            foreach (var country in Persistent.Countries.GetAll())
            {
                if (embargoedCountries.Contains(country.ID))
                {
                    continue;
                }

                var item = new SelectListItem()
                {
                    Value = country.ID.ToString(),
                    Text  = country.Entity.Name
                };

                Countries.Add(item);
            }
        }
Exemplo n.º 2
0
        public void LoadCurrents(AbsolutePlace place)
        {
            var countries = namazApi.GetCountries();

            countries.ForEach(c => Countries.Add(c));

            if (!string.IsNullOrWhiteSpace(place.Country?.UlkeID) &&
                Countries.Any())
            {
                var selectedCnt = Countries.FirstOrDefault(c => c.UlkeID == place.Country?.UlkeID);
                SelectedCountry = selectedCnt;

                var cities = namazApi.GetCities(selectedCnt.UlkeID);
                cities.ForEach(c => Cities.Add(c));

                if (!string.IsNullOrWhiteSpace(place.City?.SehirID))
                {
                    var selectedCity = Cities.FirstOrDefault(c => c.SehirID == place.City?.SehirID);
                    SelectedCity = selectedCity;

                    var towns = namazApi.GetTowns(selectedCity.SehirID);
                    towns.ForEach(i => Towns.Add(i));
                    if (!string.IsNullOrWhiteSpace(place.Town?.IlceID))
                    {
                        var selectedTown = Towns.FirstOrDefault(t => t.IlceID == place.Town?.IlceID);
                        SelectedTown = SelectedTown;
                    }
                    else
                    {
                        var cityCenter = towns.FirstOrDefault(t => t.IlceAdi == selectedCity.SehirAdi);
                        SelectedTown = cityCenter;
                    }
                }
            }
        }
        public ApplicationCountryViewModel()
        {
            List <Country> collection = CountryService.GetCountries();

            foreach (Country c in collection)
            {
                Countries.Add(new CountryModel(c));
            }

            Countries.CollectionChanged += (s, e) =>
            {
                if (e.Action.ToString().Equals("Add"))
                {
                    CountryModel countryModel = null;
                    foreach (CountryModel cm in e.NewItems)
                    {
                        countryModel = cm;
                    }

                    CountryService.AddCountry(countryModel.Country);
                }
                else if (e.Action.ToString().Equals("Remove"))
                {
                    CountryModel countryModel = null;
                    foreach (CountryModel cm in e.OldItems)
                    {
                        countryModel = cm;
                    }

                    CountryService.RemoveCountry(countryModel.Country);
                }
                OnPropertyChanged("Countries");
            };
        }
Exemplo n.º 4
0
        private void SeedReferenceData()
        {
            var seeded = false;

            if (Roles.Count() == 0)
            {
                foreach (var role in Role.GetSeedData())
                {
                    Roles.Add(role);
                }
                seeded = true;
            }

            if (Countries.Count() == 0)
            {
                foreach (var country in Country.GetSeedData())
                {
                    Countries.Add(country);
                }
                seeded = true;
            }

            if (seeded)
            {
                this.SaveChanges();
            }
        }
Exemplo n.º 5
0
        //Statische Methoden, aufgerufen von der Starter-Klasse, damit alle Datenbank-Aufrufe über dieses Objekt in der
        //derselben Klasse gesammelt sind


        //bei Select * Abfrage gibt er folgende Reihenfolge aus: postID, uid, cid, date, content, tid, cid, name, tid, name, uid, username, pwHash, admin

        internal static Countries getAllCountries()
        {
            SqlCommand    cmd          = new SqlCommand("select c.cid, c.name, p.postID from Countries as c left join Posts as p on c.cid = p.cid", Starter.GetConnection());
            SqlDataReader reader       = cmd.ExecuteReader();
            Countries     allCountries = new Countries(); //initialisiere lehre Liste

            Country currentObject = new Country();

            currentObject.cID = 0;

            while (reader.Read())
            {
                if (currentObject.cID != reader.GetInt32(0))
                {
                    Country oneCountry = new Country();
                    currentObject = oneCountry;
                    allCountries.Add(currentObject);
                    currentObject.cID         = reader.GetInt32(0);
                    currentObject.countryName = reader.GetString(1);
                }

                try
                {
                    currentObject.postIDs.Add(reader.GetInt32(2));
                }
                catch (Exception e) {
                }
            }
            return(allCountries);
        }
Exemplo n.º 6
0
        public void TokenCallback(ParadoxParser parser, string token)
        {
            switch (token)
            {
            case "players_countries":
                PlayerCountries = parser.ReadStringList();
                break;

            case "countries":
                var countriesParser = parser.Parse(new CountriesParser());
                foreach (var country in countriesParser.Countries)
                {
                    Countries.Add(new JProperty(country.Tag, JObject.FromObject(country)));
                }

                break;

            case "diplomacy":
                var diplomacyParser = parser.Parse(new DiplomacyParser());
                foreach (var keyValue in diplomacyParser.DiplomaciesByType)
                {
                    var jArray = new JArray(keyValue.Value.Select(p => JObject.FromObject(p)));
                    Diplomacy.Add(new JProperty(keyValue.Key, jArray));
                }

                break;
            }
        }
Exemplo n.º 7
0
        public static void GetCountriesAsGenericListUsingCustomGetFieldValue()
        {
            Countries.Clear();
            string ResultText = null;

            using (SqlConnection cnn = new SqlConnection(Config.ConnectionString))
            {
                cnn.Open();
                using (SqlCommand cmd = new SqlCommand(CountryManager.COUNTRY_SQL, cnn))
                {
                    using (SqlDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection))
                    {
                        while (dr.Read())
                        {
                            Countries.Add(new Country
                            {
                                CountryId           = dr.CustomGetFieldValue <int>("CountryId"),
                                IsDeleted           = dr.CustomGetFieldValue <bool>("IsDeleted"),
                                CountryAbbreviation = dr.CustomGetFieldValue <string>("CountryAbbreviation"),
                                CountryName         = dr.CustomGetFieldValue <string>("CountryName"),
                                CountryCallingCode  = dr.CustomGetFieldValue <string>("CountryCallingCode")
                            });
                        }
                    }
                }
            }
            foreach (var item in Countries)
            {
                Console.WriteLine(JsonConvert.SerializeObject(item));
            }
        }
Exemplo n.º 8
0
        async Task ExecuteLoadItemsCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                Countries.Clear();
                var items = App.Database.GetCountries();
                foreach (var item in items.Result.OrderBy(c => c.Name))
                {
                    Countries.Add(item);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
Exemplo n.º 9
0
        public override void PopulateList()
        {
            if (Countries == null)
            {
                Countries = new List <CountryModel>();
            }

            Countries.Clear();

            foreach (DataRow row in _dataTable.Select(null, "Entity_Name", DataViewRowState.CurrentRows))
            {
                CountryModel country = new CountryModel()
                {
                    Code    = (int)row.Field <Int64>("Country_Code"),
                    Name    = row.Field <string>("Entity_Name"),
                    Deleted = row.Field <bool>("Deleted")
                };

                if (country.Deleted == false || IncludeDeleted == true)
                {
                    Countries.Add(country);
                }
            }

            _dataTable = null;
        }
Exemplo n.º 10
0
        public void Parse(string file)
        {
            string[] lines = File.ReadAllLines(file);
            List <List <string> > CountryRaw = new List <List <string> >();
            List <string>         s          = new List <string>();

            foreach (string line in lines)
            {
                if (line[0] != ' ' && line[0] != '#') //Current country
                {
                    if (s.Count > 0)
                    {
                        CountryRaw.Add(s);
                        s = new List <string>();
                    }
                }
                s.Add(line);
            }

            foreach (var raw in CountryRaw)
            {
                Country country = new Country(raw[0]);
                Countries.Add(country);
                for (int i = 1; i < raw.Count; i++)
                {
                    ParseCallRows(raw[i], country);
                }
            }
        }
Exemplo n.º 11
0
        public CitizenTravelViewModel(Entities.Citizen citizen, IList <MovingTicket> availableTickets, IFriendService friendService)
        {
            Info = new CitizenInfoViewModel(citizen, friendService);

            IEnumerable <Entities.Country> countries = Persistent.Countries.GetAll();

            Countries.Add(new SelectListItem()
            {
                Text  = "-- Select country --",
                Value = "null"
            });

            foreach (var country in countries)
            {
                Countries.Add(new SelectListItem()
                {
                    Text  = country.Entity.Name,
                    Value = country.ID.ToString()
                });
            }

            foreach (var ticket in availableTickets.OrderBy(t => t.Quality))
            {
                AvailableMovingTicketQualities.Add(new SelectListItem()
                {
                    Text  = ticket.Quality.ToString(),
                    Value = ticket.Quality.ToString()
                });
            }
        }
Exemplo n.º 12
0
        /// <summary>
        /// Helper function to create a new country
        /// </summary>
        /// <param name="countryName">Name of Country</param>
        /// <param name="capitalName">Captial of Country</param>
        /// <param name="cities">Cities of Country</param>
        /// <returns>new Country object</returns>
        public Country CreateCountry(string countryName, string capitalName, string[] cities)
        {
            City    capital = new() { Name = capitalName };
            Country country = new() { Name = countryName, Capital = capital };

            Countries.Add(country);
            SaveChanges();

            var ct = Countries
                     .Include(c => c.Cities)
                     .FirstOrDefault(c => c.Id == country.Id);

            if (ct != null)
            {
                ct.Cities.Add(capital);

                foreach (string cityName in cities)
                {
                    City c = new() { Name = cityName };
                    ct.Cities.Add(c);
                }
                SaveChanges();
            }
            return(ct);
        }
    }
}
Exemplo n.º 13
0
 public void TokenCallback(ParadoxParser parser, string token)
 {
     if (parser.CurrentIndent == 1)
     {
         Countries.Add(parser.Parse(new Country(token)));
     }
 }
Exemplo n.º 14
0
        public static void GetCountriesAsGenericListUsingGetFieldValue()
        {
            Countries.Clear();
            string ResultText = null;

            using (SqlConnection cnn = new SqlConnection(Config.ConnectionString))
            {
                cnn.Open();
                using (SqlCommand cmd = new SqlCommand(CountryManager.COUNTRY_SQL, cnn))
                {
                    using (SqlDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection))
                    {
                        while (dr.Read())
                        {
                            Countries.Add(new Country
                            {
                                CountryId           = dr.GetFieldValue <int>(dr.GetOrdinal("Countryid")),
                                IsDeleted           = dr.GetFieldValue <bool>(dr.GetOrdinal("IsDeleted")),
                                CountryAbbreviation = dr.GetFieldValue <string>(dr.GetOrdinal("CountryAbbreviation")),
                                CountryName         = dr.GetFieldValue <string>(dr.GetOrdinal("CountryName")),
                                //GetFieldValue<T>() does not work on below nullable type
                                CountryCallingCode = dr.IsDBNull(dr.GetOrdinal("CountryCallingCode"))
                                                        ? "shound not be null"
                                                        : dr["CountryCallingCode"].ToString()
                            });
                        }
                    }
                }
            }
            foreach (var item in Countries)
            {
                Console.WriteLine(JsonConvert.SerializeObject(item));
            }
        }
Exemplo n.º 15
0
 private void ExecuteAddNew(object parameter)
 {
     Countries.Add(new CountryModel()
     {
         ID = 0, Name = string.Empty, OperatingCompanyID = 0
     });
     ScrollToSelectedItem = Countries.Count - 1;
 }
Exemplo n.º 16
0
 public DomainUpDownViewModel()
 {
     Countries.Add("Asia");
     Countries.Add("Europe");
     Countries.Add("Australia");
     Countries.Add("Africa");
     Countries.Add("America");
     Countries.Add("Antarctica");
 }
Exemplo n.º 17
0
 private void FillCountries()
 {
     Countries.Clear();
     foreach (var item in db.Countries.ToList())
     {
         Countries.Add(item);
     }
     CountryCount = Countries.Count;
 }
        private void LoadCountries()
        {
            var newCountries = Task.Run(countryRepository.LoadCountries).Result;

            foreach (var country in newCountries)
            {
                Countries.Add(country);
            }
        }
 public AirportsViewModel(IEnumerable <string> cities)
 {
     Countries.Add(new SelectListItem {
         Text = "All", Value = "All"
     });
     Countries.AddRange(cities.Select(c => new SelectListItem {
         Text = c, Value = c
     }));
 }
Exemplo n.º 20
0
        private void ExecuteSearchCountryCommand()
        {
            var cultureInfoPtBR = App.AppCultureInfo.Equals("pt");
            IEnumerable <Country> countries;

            if (string.IsNullOrEmpty(SearchText))
            {
                ItemTreshold = 1;
                Countries.Clear();

                if (cultureInfoPtBR)
                {
                    countries = _db.FindAll().OrderBy(p => p.countryPtBR).Take(20);
                }
                else
                {
                    countries = _db.FindAll().OrderBy(p => p.country).Take(20);
                }

                foreach (var item in _db.FindAll().Take(20))
                {
                    Countries.Add(item);
                }
            }
            else
            {
                ItemTreshold = -1;
                Countries.Clear();

                try
                {
                    if (cultureInfoPtBR)
                    {
                        countries = _db.FindAll()
                                    .Where(p => p.countryPtBR.ToLower().RemoveAccents().Contains(SearchText.ToLower().RemoveAccents()))
                                    .OrderBy(p => p.countryPtBR)
                                    .ToList();
                    }
                    else
                    {
                        countries = _db.FindAll()
                                    .Where(p => p.country.ToLower().Contains(SearchText.ToLower()))
                                    .ToList();
                    }

                    foreach (var item in countries)
                    {
                        Countries.Add(item);
                    }
                }
                catch (Exception ex)
                {
                    var error = ex.Message;
                }
            }
        }
        public void AddCountry()
        {
            var name = "Country " + Countries.Count;

            CountryNames.Add(name);
            Countries.Add(new CountryData()
            {
                Id = Countries.Count + 1, Name = name
            });
        }
        // Or alternatively you could use an expression-bodied get statement
        // public IEnumerable<Country> Countries => countries;

        public void AddCountry(Country newCountry)
        {
            // test for duplicates
            Country country = (from c in Countries where c.Name == newCountry.Name select c).FirstOrDefault();

            if (country == null)
            {
                Countries.Add(newCountry);
            }
        }
Exemplo n.º 23
0
        private void ContinentFilterSelected()
        {
            Countries.Clear();
            foreach (var country in CountriesRaw.Where(IsCountryBelongToSelectedContinent))
            {
                Countries.Add(country);
            }

            SelectedCountry = Countries[0];
        }
Exemplo n.º 24
0
        public void OnResume()
        {
            if (Packages.Count > 0)
            {
                return;
            }
            var editVM      = (BaseViewModel)_activity.ViewModel;
            var listRide    = _activity.Resources.GetStringArray(Resource.Array.lst_ride);
            var listPackage = _activity.Resources.GetStringArray(Resource.Array.lst_package);
            //country & city
            var listcontries = _activity.Resources.GetStringArray(Resource.Array.lst_country);
            var listcity     = _activity.Resources.GetStringArray(Resource.Array.lst_city);
            int position     = 0;

            foreach (var ride in listRide)
            {
                var itm = new ListItem {
                    DisplayName = ride, Position = position
                };
                itm.ParentSelectionChanged = editVM.WhistleEditViewModel.OnSelectionChanged; //ride selection
                Rides.Add(itm);
                position++;
            }
            position = 0;
            foreach (var p in listPackage)
            {
                var itm = new ListItem {
                    DisplayName = p, Position = position
                };
                itm.ParentSelectionChanged = editVM.WhistleEditViewModel.OnPackageSelectionchanged;
                Packages.Add(itm);
                position++;
            }

            position = 0;
            foreach (var count in listcontries)
            {
                var itm = new ListItem {
                    DisplayName = count, Position = position
                };
                itm.ParentSelectionChanged = editVM.WhistleEditViewModel.OnContrySelectionChanged;
                Countries.Add(itm);
                position++;
            }
            position = 0;
            foreach (var city in listcity)
            {
                var itm = new ListItem {
                    DisplayName = city, Position = position
                };
                itm.ParentSelectionChanged = editVM.WhistleEditViewModel.OnSelectionChanged;
                Cities.Add(itm);
                position++;
            }
        }
Exemplo n.º 25
0
 private void SettingsChanged(object o)
 {
     if (countries.Count == 0)
     {
         JsonHelper.StoreData <State>("countries.json", string.Format("{0}token={1}", urlStatesRequest, apiKey));
         foreach (State state in JsonHelper.States)
         {
             Countries.Add(state.Name);
         }
     }
 }
    Country CreateCountry(string name)
    {
        var c = new Country()
        {
            CountryName = name
        };

        c.CountryID = Countries.Count;
        Countries.Add(c);
        return(c);
    }
Exemplo n.º 27
0
        private void GetAllCountries()
        {
            Countries.Clear();
            IEnumerable <Country> countries;

            countries = App.AppCultureInfo.Equals("pt") ? _db.FindAll().OrderBy(p => p.countryPtBR).Take(20) : _db.FindAll().Take(20);
            foreach (var item in countries)
            {
                Countries.Add(item);
            }
        }
Exemplo n.º 28
0
        public async void MakeRequest()
        {
            Info info = await CovidHelper.GetInfo();

            Global = info.Global;
            Countries.Clear();
            foreach (var item in info.Countries)
            {
                Countries.Add(item);
            }
        }
Exemplo n.º 29
0
        public void ClaimCountry(Country country)
        {
            if (country.OccupyingPlayer != null)
            {
                throw new Exception($"Unable to claim {country.Name} for {Name} because it is already claimed by {country.OccupyingPlayer.Name}.");
            }

            country.OccupyingPlayer = this;
            Countries.Add(country);
            DropArmies(country, 1);
        }
Exemplo n.º 30
0
        private async void UpdateCountries()
        {
            var CountriesAPIList = await RapidFutballHelper.GetCountries();

            Countries.Clear();
            Teams.Clear();
            foreach (var Country in CountriesAPIList)
            {
                Countries.Add(Country);
            }
        }