public Schedule() { InitializeComponent(); this._value = new GraphicValue(this.InitializeGraphic()); this.uiMonther.SelectedIndex = 0; this.CityList = new List <string>(); this.CoordinatesDictionary = new Dictionary <string, CityCoordinates>(); InitializeCityDictionary(); this.SelectedCity = CityList.First(); this.UpdateBinding(); this.uiLatitude.Text = Latitude.ToString(); this.uiLongitude.Text = Longitude.ToString(); this.uiCityList.ItemsSource = CityList.ToList(); this.uiCityList.SelectedItem = CityList.First(); this.uiCalculateButton.Command = CalculateScheduleCommand; //if(Name== "uiLightingSchedule") //{ // uiSolarExpander.Visibility = Visibility.Visible; //} //else //{ // uiSolarExpander.Visibility = Visibility.Collapsed; //} }
/// <summary> /// 初始化编辑时地址下拉框 /// </summary> /// <param name="user"></param> public void InitialEditAddress(DataOfUserDetial user) { CountryList.Clear(); ProvinceList.Clear(); CityList.Clear(); AreaList.Clear(); var countryList = new Areas() { parent_id = 0, type = 1 }.GetChildrenList(); var provinceList = new Areas() { parent_id = 1 /*user.countryId*/, type = 2 }.GetChildrenList(); var cityList = new Areas() { parent_id = user.provinceId, type = 3 }.GetChildrenList(); var areaList = new Areas() { parent_id = user.cityId, type = 4 }.GetChildrenList(); CountryList.AddRange(countryList.ToObservableCollection()); ProvinceList.AddRange(provinceList.ToObservableCollection()); CityList.AddRange(cityList.ToObservableCollection()); AreaList.AddRange(areaList.ToObservableCollection()); CountryIndex = 1; //user.countryId; ProvinceIndex = user.provinceId; CityIndex = user.cityId; AreaIndex = user.areaId; }
public void ShouldReturnEmptyList() { CityList cityList = new CityList(); List <City> list = cityList.GetList(); Assert.AreEqual(list.Count, 0); }
public IHttpActionResult PutCityList(int id, CityList cityList) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != cityList.id) { return(BadRequest()); } db.Entry(cityList).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!CityListExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public void CheckIfGetInvalidId() { var expected = -1; var actual = CityList.GetCityId("London", "UK"); Assert.AreEqual(expected, actual); }
/// <summary> /// Event handler for "select" button in GUI, means the User has selected an option /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnChoose_Click(object sender, EventArgs e) { hasGuessed = true; btnChoose.Enabled = false; string value = CityList.GetItemText(CityList.SelectedItem); value = value.Trim(); string key = lblQuestion.Text.Substring(23, lblQuestion.Text.Substring(23).Length - 1); //if the guess was correct if (CapitalCities[key] == value) { Countdown.Stop(); lblright.Visible = true; int n = Int32.Parse(txtCorrect.Text); int m = Int32.Parse(txtAttempts.Text); n++; m++; txtCorrect.Text = n.ToString(); txtAttempts.Text = m.ToString(); } //if it wasn't else { Countdown.Stop(); lblwrong.Visible = true; int m = Int32.Parse(txtAttempts.Text); m++; txtAttempts.Text = m.ToString(); } }
public List <City> FindNeighbours(WayPoint location, double distance) { return(CityList .Where(c => location.Distance(c.Location) <= distance) .OrderBy(c => location.Distance(c.Location)) .ToList()); }
/** * When a state is selected, load all its cities in the City combo box. * If "All states" selected, don't load anything. */ private void cmbState_SelectedIndexChanged(object sender, EventArgs e) { try { if (cmbState.SelectedIndex < 0) { return; } if (cmbState.SelectedIndex == 0) { cmbCity.Items.Clear(); cmbCity.Text = " ---- cities ----"; return; } cmbCity.Enabled = false; State selectedState = (State)cmbState.SelectedItem; CityList stateCities = _presenter.GetCities(selectedState).Result; cmbCity.Items.Clear(); foreach (City city in stateCities.Cities) { cmbCity.Items.Add(city); } cmbCity.Text = " ---- cities ----"; cmbCity.Enabled = true; } catch (AggregateException aex) { HandleAggregateException(aex); } catch (Exception ex) { HandleGeneralException(ex); } }
public async Task <ActionResult> CriaBeaconAsync() { DataService dataService = new DataService(); List <Admin> admin = new List <Admin>(); admin = await dataService.GetAdminAsync(); List <ListaAdminB> ad = new List <ListaAdminB>(); ListaAdminB adm; for (int i = 0; i < admin.Count; i++) { adm = new ListaAdminB(); adm.Email = admin[i].email; adm.NomeAdmin = admin[i].name; adm.Username = admin[i].username; ad.Add(adm); } CityList objBind = new CityList(); objBind.list = ad; // IEnumerable<ListaAdminB> myEnumerable = (IEnumerable<ListaAdminB>)ad; return(View(objBind)); }
private void LoadDictionary(DataSet ds) { // Retrieving the list of Cities to find the City of each Employee. CityList cityList = new CityList(); foreach (DataRow row in ds.Tables[0].Rows) { Permission permissions = new Permission(); permissions.ManageEmployees = (bool)row["ManageEmployees"]; permissions.ManageAllClients = (bool)row["ManageAllClients"]; permissions.ManageOwnClients = (bool)row["ManageOwnClients"]; permissions.ManageAllHouses = (bool)row["ManageAllHouses"]; permissions.ManageOwnHouses = (bool)row["ManageOwnHouses"]; permissions.ManageAllSales = (bool)row["ManageAllSales"]; permissions.ManageOwnSales = (bool)row["ManageOwnSales"]; Employee employee = new Employee(); employee.EmployeeId = (int)row["EmployeeId"]; employee.FirstName = row["FirstName"].ToString(); employee.LastName = row["LastName"].ToString(); employee.BirthDate = (DateTime)row["BirthDate"]; employee.Email = row["Email"].ToString(); employee.Phone = row["Phone"].ToString(); employee.City = cityList.FindByCityId((int)row["CityId"]); employee.Position = (Position)row["PositionId"]; employee.Salary = (double)row["Salary"]; employee.Username = row["Username"].ToString(); employee.Password = row["UserPassword"].ToString(); employee.Permissions = permissions; _list.Add(employee.EmployeeId, employee); } }
/// <summary> /// Find all cities between 2 cities /// </summary> /// <param name="from">source city</param> /// <param name="to">target city</param> /// <returns>list of cities</returns> public List <City> FindCitiesBetween(City from, City to) { var foundCities = new List <City>(); if (from == null || to == null) { return(foundCities); } foundCities.Add(from); var minLat = Math.Min(from.Location.Latitude, to.Location.Latitude); var maxLat = Math.Max(from.Location.Latitude, to.Location.Latitude); var minLon = Math.Min(from.Location.Longitude, to.Location.Longitude); var maxLon = Math.Max(from.Location.Longitude, to.Location.Longitude); // renames the name of the "cities" variable to your name of the internal City-List foundCities.AddRange(CityList.FindAll(c => c.Location.Latitude > minLat && c.Location.Latitude <maxLat && c.Location.Longitude> minLon && c.Location.Longitude < maxLon)); foundCities.Add(to); InitIndexForAlgorithm(foundCities); return(foundCities); }
public void CheckIfGetValidId() { var expected = 2643743; var actual = CityList.GetCityId("London", "GB"); Assert.AreEqual(expected, actual); }
private static IHost ConfigureHost(CityList cities) { return(new HostBuilder() .ConfigureHostConfiguration(configHost => { configHost.SetBasePath(Directory.GetCurrentDirectory()); configHost.AddJsonFile("hostsettings.json", optional: true); configHost.AddEnvironmentVariables(prefix: "PREFIX_"); }) .ConfigureAppConfiguration((hostContext, configApp) => { configApp.AddJsonFile("appsettings.json", optional: true); configApp.AddJsonFile( $"appsettings.{hostContext.HostingEnvironment.EnvironmentName}.json", optional: true); configApp.AddEnvironmentVariables(prefix: "PREFIX_"); }) .ConfigureServices((hostContext, services) => { services.AddSingleton <CityList>(cities); services.AddHostedService <TimerHostedService>(); services.AddScoped <IWeatherProcessor, WeatherProcessor>(); services.AddHttpClient(); }) .ConfigureLogging((hostContext, configLogging) => { configLogging.AddConsole(); configLogging.AddDebug(); }) .UseConsoleLifetime() .Build()); }
public void ClearAll() { PlayerList.Clear(); CityList.Clear(); ArmyList.Clear(); ResearchList.Clear(); DebugList.Clear(); }
public CityListTest() { _mockLogger = new Mock <ILogger <CityList> >(); _dynamoDbClient = new Mock <IDynamoDbClient>(); _mapper = new Mock <IMapper>(); _cityList = new CityList(_mockLogger.Object, _dynamoDbClient.Object, _mapper.Object); }
public WeatherForecastController(ILogger <WeatherForecastController> logger, IConfiguration configuration, CurrentWeatherData currentWeatherData, EmailService emailService, CityList cityList) { _logger = logger; _configuration = configuration; _currentWeatherData = currentWeatherData; _emailService = emailService; _cityList = cityList; }
void UpdateCities(object parameter) { var cities = DarkSkyWrapper.GetCities(); foreach (KeyValuePair <string, string> c in cities) { CityList.Add(c.Key); } }
public void ShouldReturnFalseWhenLookingForCity() { CityList cityList = new CityList(); City city = new City("Przesieka"); cityList.AddElement(city); Assert.IsFalse(cityList.CheckCityExistsInList("Karpacz")); }
protected override async Task MapEditedItemToEditor(Branch item) { SelectedCountry = CountryList.FirstOrDefault(e => e.Id == item.CountryId); await OnCountrySelected(SelectedCountry); SelectedCity = CityList.FirstOrDefault(e => e.Id == item.CityId); SelectedCompany = CompanyList.FirstOrDefault(e => e.Id == item.CompanyId); await base.MapEditedItemToEditor(item); }
private bool CreateCityFolder(CityList city) { string cityDir = $"{AppDomain.CurrentDomain.BaseDirectory}{outputDir}\\{city.Id}_{city.Name}"; if (!Directory.Exists(cityDir)) { Directory.CreateDirectory(cityDir); } return(true); }
public CityData ConvertCityFromDB() { DataTable tab = GetCityFromDB(); DataRow row = tab.Rows[0]; cityList = jsonParser.Parsing(row["CityName"].ToString()); cityData = ConvertClasses(cityList); cityData.Id = Convert.ToInt32(row["Id"]); return(cityData); }
public AddCity(MySqlConnectionStringBuilder mysqlCSB, string nameTrack) { this.nametrack = nameTrack; this.mysqlCSB = mysqlCSB; InitializeComponent(); LoadCity(); comboBox1.Items.AddRange(CityList.ToArray()); comboBox1.SelectedIndex = 0; comboBox1.Refresh(); }
public EditCitysInTrack(string nameTrack, MySqlConnectionStringBuilder mysqlCSB) { this.nameTrack = nameTrack; this.mysqlCSB = mysqlCSB; InitializeComponent(); this.Text = nameTrack; LoadCity(); listBox1.Items.AddRange(CityList.ToArray()); listBox1.Refresh(); }
private void GetCitiesList() { CityList?.Clear(); if (SelectedStateId.HasValue) { CityList = AsyncHelper.RunSync <IList <City> >(() => CitySelectorService. GetCities(SelectedStateId.Value)); } }
public void setCityList(string state) { var location = new LocationList(); CityList = location.Cities.FirstOrDefault(x => x.Key.ToLower() == StateList.FirstOrDefault(u => u.Value.ToLower() == state.ToLower()).Value.ToLower()).Value.Select(x => new SelectListItem { Text = x, Value = x }).ToList(); CityList.Insert(0, new SelectListItem { Text = "Select City", Disabled = true, Selected = true, Value = "" }); }
public IHttpActionResult GetCityList(int id) { CityList cityList = db.CityLists.Find(id); if (cityList == null) { return(NotFound()); } return(Ok(cityList)); }
public ActionResult BuildPaganationCityList(CityList model) { try { return(Json(new { NOP = (new CityModel()).BuildPaganationCityList(model) }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(new { error = ex.Message }, JsonRequestBehavior.AllowGet)); } }
public ActionResult GetCityList(CityList model) { try { return(Json((new CityModel()).GetCityList(model), JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(new { error = ex.Message }, JsonRequestBehavior.AllowGet)); } }
public void RefreshCities() { CityList.Clear(); RequestService.GetCities().ToList().ForEach(c => CityList.Add(c)); OnPropertyChanged(nameof(CityList)); SelectedCity = CityList.FirstOrDefault(); CompanyList.Clear(); RequestService.GetServiceCompanies().ToList().ForEach(c => CompanyList.Add(c)); OnPropertyChanged(nameof(CompanyList)); }
private void GetCitiesList() { CityList?.Clear(); if (SelectedStateId.HasValue) { var items = AsyncHelper.RunSync <IList <City> >(() => CitySelectorService. GetCities(SelectedStateId.Value)); CityList = items.OrderBy(x => x.Name).ToList(); } }