public ActionResult EditCustomer(int id) { using (DbContextModel db = new DbContextModel()) { try { var customer = db.Customers.Include("Address").Where(x => x.Id == id).FirstOrDefault(); var countries = CountriesManager.LoadAllCountriesFromFile(); SelectList countriesList = new SelectList(countries, "Country"); if ((TempData["Countries"] as SelectList) != null) { var countriesSelectList = TempData["Countries"] as SelectList; var selectedCountries = countriesSelectList.Items; } TempData["Countries"] = countriesList; return(View("EditCustomer", customer)); } catch (Exception) { return(RedirectToAction("Customers")); } } }
private void InitializeDataBinding() { // Log data _qsoLog = new QSOLog(Properties.Settings.Default.LogPath); qsoGrid.ItemsSource = _qsoLog.QSOs; // Type data _typeDataDb = new TypeDataDb(); _bandsManager = new BandsManager(_typeDataDb); _modesManager = new ModesManager(_typeDataDb); _countriesManager = new CountriesManager(_typeDataDb); _statesManager = new StatesManager(_typeDataDb); _bandsManager.LoadAndUpdate(); _modesManager.LoadAndUpdate(); _countriesManager.LoadAndUpdate(); _statesManager.LoadAndUpdate(); bandTxt.ItemsSource = _bandsManager.Bands; modeTxt.ItemsSource = _modesManager.Modes; countryTxt.ItemsSource = _countriesManager.Countries; stateTxt.ItemsSource = _statesManager.States; }
public CountriesController(ILogger <CountriesController> logger, IMapper mapper, IRepository <CountryEntity> repository) { _logger = logger; _mapper = mapper; _repository = repository; _manager = new CountriesManager(_mapper, _repository); }
public void GetByKeyTest() { CountriesManager target = new CountriesManager(); //Country expected = null; // TODO: Initialize to an appropriate value Country actual; actual = target.GetByKey(TEST_CODE); Assert.IsTrue(actual.Code == TEST_CODE); }
public void GetListTest() { CountriesManager target = new CountriesManager(); // TODO: Initialize to an appropriate value Dictionary<string, string> expected = null; // TODO: Initialize to an appropriate value Dictionary<string, string> actual; actual = target.GetList(); Assert.AreEqual(expected, actual); Assert.IsTrue(actual.Count > 0); }
public ActionResult Index() { manager = new CountriesManager(); initialiceCountries = new List <int>(); ViewBag.myTroopLimit = manager.TroopdforAssign(1); ViewBag.IATroopLimit = manager.TroopdforAssign(2); return(View()); }
/// <summary> /// Testing single responsibility principle /// </summary> /// <returns></returns> private async static Task TestCountries() { CountriesManager manager = new CountriesManager(); var countries = await manager.GetCountries(); foreach (var country in countries) { Console.WriteLine(CountriesFormatter.FormatForConsole(country)); } }
private async static Task testCountries() { CountriesManager manager = new CountriesManager(); var countries = await manager.GetEuropeanCountries(); foreach (var country in countries) { Console.WriteLine(country.ToString()); } }
public void DiscoverIp(ConnectionInfo connection) { IpAddress ip = connection.IpsEntry.FirstPreferIPv4; if (ip != null) { Json jDoc = DiscoverIpData(ip.Address, ""); if (jDoc != null) { // Node parsing if (jDoc.HasKey("country_code")) { string countryCode = Conversions.ToString(jDoc["country_code"].Value).Trim().ToLowerInvariant(); if (CountriesManager.IsCountryCode(countryCode)) { if (connection.CountryCode != countryCode) { connection.CountryCode = countryCode; Engine.Instance.MarkServersListUpdated(); Engine.Instance.MarkAreasListUpdated(); } } } if (jDoc.HasKey("city_name")) { string cityName = Conversions.ToString(jDoc["city_name"].Value).Trim(); if (cityName == "N/A") { cityName = ""; } if (cityName != "") { connection.Location = cityName; Engine.Instance.MarkServersListUpdated(); } } if ((jDoc.HasKey("latitude")) && (jDoc.HasKey("longitude"))) { double latitude = Conversions.ToDouble(jDoc["latitude"].Value); double longitude = Conversions.ToDouble(jDoc["longitude"].Value); connection.Latitude = latitude; connection.Longitude = longitude; Engine.Instance.MarkServersListUpdated(); } } } connection.LastDiscover = UtilsCore.UnixTimeStamp(); connection.Provider.OnChangeConnection(connection); }
private async static Task testCountries() { CountriesManager manager = new CountriesManager(); CountryFormatter formatter = new CountryFormatter(); var countries = await manager.GetEuropeanCountries(); countries.ToList() .ForEach(x => { WriteLine(formatter.Format(x)); }); }
public void GetByFilterTest() { CountriesManager target = new CountriesManager(); // TODO: Initialize to an appropriate value CountriesFilter filter = null; // TODO: Initialize to an appropriate value filter.Code = TEST_CODE; List<Country> actual; actual = target.GetByFilter(filter, ""); Assert.IsTrue(actual[0].Code == TEST_CODE); //Assert.AreEqual(expected, actual); //Assert.Inconclusive("Verify the correctness of this test method."); }
public ActionResult Index() { var countries = CountriesManager.LoadAllCountriesFromFile(); SelectList countriesList = new SelectList(countries, "Country"); if ((TempData["Countries"] as SelectList) != null) { var countriesSelectList = TempData["Countries"] as SelectList; var selectedCountries = countriesSelectList.Items; } TempData["Countries"] = countriesList; return(View()); }
public void DiscoverIp(ConnectionInfo connection) { XmlDocument xmlDoc = DiscoverIpData(connection.IpsEntry.ToStringFirstIPv4(), ""); if (xmlDoc != null) { // Node parsing string countryCode = Utils.XmlGetBody(xmlDoc.DocumentElement.SelectSingleNode(".//country_code") as XmlElement).ToLowerInvariant().Trim(); if (CountriesManager.IsCountryCode(countryCode)) { if (connection.CountryCode != countryCode) { connection.CountryCode = countryCode; Engine.Instance.MarkServersListUpdated(); Engine.Instance.MarkAreasListUpdated(); } } string cityName = Utils.XmlGetBody(xmlDoc.DocumentElement.SelectSingleNode(".//city_name") as XmlElement).Trim(); if (cityName == "N/A") { cityName = ""; } if (cityName != "") { connection.Location = cityName; Engine.Instance.MarkServersListUpdated(); } float latitude = Conversions.ToFloat(Utils.XmlGetBody(xmlDoc.DocumentElement.SelectSingleNode(".//latitude") as XmlElement).Trim()); float longitude = Conversions.ToFloat(Utils.XmlGetBody(xmlDoc.DocumentElement.SelectSingleNode(".//longitude") as XmlElement).Trim()); if ((latitude != 0) && (longitude != 0)) { connection.Latitude = latitude; connection.Longitude = longitude; Engine.Instance.MarkServersListUpdated(); } } connection.LastDiscover = Utils.UnixTimeStamp(); connection.Provider.OnChangeConnection(connection); }
public ActionResult Index(CustomerModel customer) { var countries = CountriesManager.LoadAllCountriesFromFile(); SelectList countriesList = new SelectList(countries, "Country"); if ((TempData["Countries"] as SelectList) != null) { var countriesSelectList = TempData["Countries"] as SelectList; var selectedCountries = countriesSelectList.Items; } TempData["Countries"] = countriesList; if (ModelState.IsValid) { CustomerManager.AddNewCustomer(customer); ViewBag.AlertSuccess = true; ModelState.Clear(); return(View()); } ViewBag.AlertSuccess = false; return(View()); }
public void DiscoverIp(ServerInfo server) { string[] methods = Engine.Instance.Storage.Get("discover.ip_webservice.list").Split(';'); bool onlyFirstResponse = Engine.Instance.Storage.GetBool("discover.ip_webservice.first"); foreach (string method in methods) { try { if ((method.StartsWith("http://")) || (method.StartsWith("https://"))) { // Fetch a webservice string url = method; url = url.Replace("{@ip}", server.IpEntry); XmlDocument xmlDoc = Engine.Instance.XmlFromUrl(url, null, "iptitle", false); // Clodo: Bypass proxy? if (xmlDoc.DocumentElement.HasChildNodes) { // Node renaming Utils.XmlRenameTagName(xmlDoc.DocumentElement, "CountryCode", "country_code"); // Node parsing //string countryCode = Utils.XmlGetBody(Utils.XmlGetFirstElementByTagName(xmlDoc.DocumentElement, "country_code")).ToLowerInvariant().Trim(); string countryCode = Utils.XmlGetBody(xmlDoc.DocumentElement.SelectSingleNode(".//country_code") as XmlElement).ToLowerInvariant().Trim(); if (CountriesManager.IsCountryCode(countryCode)) { if (server.CountryCode != countryCode) { server.CountryCode = countryCode; Engine.Instance.MarkServersListUpdated(); Engine.Instance.MarkAreasListUpdated(); } } string cityName = Utils.XmlGetBody(xmlDoc.DocumentElement.SelectSingleNode(".//city_name") as XmlElement).Trim(); if (cityName == "N/A") { cityName = ""; } if (cityName != "") { server.Location = cityName; } if (onlyFirstResponse) { break; } } else { Engine.Instance.Logs.Log(LogType.Fatal, "Unable to fetch " + url); } } } catch (Exception) { } } }
public void SetUp() { _mock = new Mock <ICountriesHttpClient>(); _manager = new CountriesManager(_mock.Object); }
public void InsertTest() { CountriesManager target = new CountriesManager(); Country theObj = null; Country actual; theObj.Code = TEST_CODE; theObj.Iso3 = "TES"; actual = target.Insert(theObj); Assert.AreEqual(theObj.Code, actual.Code); }
public void UpdateTest() { CountriesManager target = new CountriesManager(); // TODO: Initialize to an appropriate value Country theObj = null; int actual; theObj = target.GetByKey(TEST_CODE); theObj.Iso3 = "TTT"; actual = target.Update(theObj); Assert.IsTrue(actual > 0); }