public static Bank RandomBank(CityArea ca = null) { var bank = new Bank(); ca = ca ?? CityArea.RandomAmericanCity(); var bankXml = GetBankXmlElement(ca); if (bankXml == null) { return(bank); } var city = bankXml.GetAttribute("city"); var state = bankXml.GetAttribute("us-state"); var name = bankXml.GetAttribute("name"); var abbrev = bankXml.GetAttribute("abbrev"); var rssd = bankXml.GetAttribute("rssd"); bank.BusinessAddress = new PostalAddress { CityArea = new UsCityStateZip(new AddressData { Locality = city, RegionAbbrev = state }) }; bank.Rssd = new ResearchStatisticsSupervisionDiscount { Value = rssd }; bank.RoutingNumber = RoutingTransitNumber.RandomRoutingNumber(); bank.AddName(KindsOfNames.Legal, name); bank.AddName(KindsOfNames.Abbrev, abbrev); bank.LoadXrefXmlData(); return(bank); }
public ActionResult Details(string id) { try { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CityArea cityArea = _unitOfWork.CityArea.GetByID(Convert.ToInt32(id)); CityAreaViewModel cityAreaViewModel = new CityAreaViewModel(); cityAreaViewModel.CityAreaName = cityArea.CityAreaName; cityAreaViewModel.SelectedCity = cityArea.City.CityName; cityAreaViewModel.SelectedProvince = cityArea.City.Province.ProvinceName; if (cityAreaViewModel != null) { return(PartialView("_DetailsCityArea", cityAreaViewModel)); } else { return(HttpNotFound()); } } catch (Exception) { throw; } }
public ActionResult AddNew(CityAreaViewModel cityAreaViewModel) { try { if (ModelState.IsValid) { CityAreaRepository cityAreaRepository = new CityAreaRepository(new AutoSolutionContext()); bool IsExist = cityAreaRepository.isExist(cityAreaViewModel.CityAreaName, cityAreaViewModel.SelectedCity); if (!IsExist) { CityArea cityArea = new CityArea(); cityArea.CityAreaName = cityAreaViewModel.CityAreaName; cityArea.CityId = Convert.ToInt32(cityAreaViewModel.SelectedCity); _unitOfWork.CityArea.Add(cityArea); _unitOfWork.Complete(); _unitOfWork.Dispose(); return(RedirectToAction("GetCityArea")); } else { return(RedirectToAction("GetCityArea")); } } } catch (Exception) { throw; } return(View()); }
public override MapItem Deserialize(BinaryReader r) { var city = new CityArea(false); ReadKdopItem(r, city); city.Name = r.ReadToken(); city.Width = r.ReadSingle(); city.Height = r.ReadSingle(); city.Node = new UnresolvedNode(r.ReadUInt64()); return(city); }
public void CanadianTest() { var testResult = CityArea.RandomCanadianCity(); Assert.IsNotNull(testResult); Assert.IsFalse(string.IsNullOrWhiteSpace(testResult.City)); Assert.IsFalse(string.IsNullOrWhiteSpace(testResult.PostalCode)); Assert.IsFalse(string.IsNullOrWhiteSpace(testResult.Providence)); Assert.IsFalse(string.IsNullOrWhiteSpace(testResult.ProvidenceAbbrv)); Console.WriteLine(testResult.City); Console.WriteLine(testResult.ProvidenceAbbrv); Console.WriteLine(testResult.Providence); Console.WriteLine(testResult.PostalCode); }
void MakeCityAreaIcon(CityArea cityArea) { if (Camera.main == null) { return; } var newClone = Instantiate ( iconObject, Camera.main.WorldToScreenPoint(cityArea.transform.position + posCorrection), Quaternion.identity, _canvas.transform.Find("IconManager") ); iconList.Add(newClone); }
public void Update(CityArea city, float speed, float straightRate) { var road = city.Roads[this.roadID]; if (this.GetProgress() >= 1f) { this.SetNextRoad(road, city, straightRate); road = city.Roads[this.roadID]; } else { this.progress = Mathf.Min(this.magnitude, this.progress + speed); } this.pos = Vector2.Lerp(this.from, this.to, this.GetProgress()); }
public void AmericanTest() { var testResult = CityArea.RandomAmericanCity(); Assert.IsNotNull(testResult); Assert.IsFalse(string.IsNullOrWhiteSpace(testResult.City)); Assert.IsFalse(string.IsNullOrWhiteSpace(testResult.ZipCode)); Assert.IsFalse(string.IsNullOrWhiteSpace(testResult.StateAbbrev)); Assert.IsFalse(string.IsNullOrWhiteSpace(testResult.PostalCodeAddonFour)); Console.WriteLine(testResult.City); Console.WriteLine(testResult.StateAbbrev); Console.WriteLine(testResult.ZipCode); Console.WriteLine(testResult.CbsaCode); Console.WriteLine(testResult.Msa); Console.WriteLine(testResult.AverageEarnings); }
public void TestToData() { IObviate testSubject = CityArea.RandomAmericanCity(); var testResult = testSubject.ToData(KindsOfTextCase.Kabab); Assert.IsNotNull(testResult); Assert.AreNotEqual(0, testResult.Count); foreach (var tr in testResult.Keys) { Console.WriteLine($"{tr}, {testResult[tr]}"); } testSubject = CityArea.RandomCanadianCity(); testResult = testSubject.ToData(KindsOfTextCase.Kabab); Assert.IsNotNull(testResult); Assert.AreNotEqual(0, testResult.Count); foreach (var tr in testResult.Keys) { Console.WriteLine($"{tr}, {testResult[tr]}"); } }
private void SetNextRoad(Road road, CityArea city, float straightRate) { if (this.isIntersection == true) { var next = city.Roads[this.nextID]; this.dir = next.Direction * (this.isForward == true ? 1f : -1f); this.magnitude = next.OffsetMagnitude; this.from = this.pos; this.to = (this.isForward == true ? next.OffsetTo : next.OffsetFrom) + (this.dir.Normal() * this.offset); this.roadID = this.nextID; this.isIntersection = false; } else { this.nextID = RoadPointer.GetNextRoadID( road, this.isForward == true ? road.ToPointID : road.FromPointID, city, straightRate); var next = city.Roads[this.nextID]; this.isForward = next.IsForward(this.to); var dir = next.Direction * (isForward == true ? 1f : -1f); this.from = this.to; this.to = (isForward == true ? next.OffsetFrom : next.OffsetTo) + dir.Normal() * this.offset; dir = this.to - this.from; this.dir = dir.normalized; this.magnitude = dir.magnitude; this.isIntersection = true; } this.progress = 0f; }
public static int GetNextRoadID(Road road, int pointID, CityArea city, float straightRate) { var ids = new List <int>(GetRoadsID(pointID)); for (var i = 0; i < ids.Count; i++) { var id = ids[i]; if (id == road.Id) { ids.Remove(road.Id); i--; continue; } var d = Vector2.Dot(road.Direction, city.Roads[id].Direction); if (Mathf.Abs(d - 1f) <= Vector2.kEpsilon && Random.value <= straightRate) { return(id); } } return(ids[Random.Range(0, ids.Count)]); }
/// <summary> /// Picks a single xml element at random from the US Banks data file /// first attempting to match on <see cref="ca"/>, if given. /// </summary> /// <param name="ca"></param> /// <returns></returns> internal static XmlElement GetBankXmlElement(CityArea ca) { UsBanksXml = UsBanksXml ?? XmlDocXrefIdentifier.GetEmbeddedXmlDoc(US_BANKS, Assembly.GetExecutingAssembly()); if (UsBanksXml == null) { return(null); } XmlElement bankXmlElem = null; var pickFromList = new List <XmlElement>(); if (!string.IsNullOrWhiteSpace(ca?.City) && !string.IsNullOrWhiteSpace(ca.GetRegionAbbrev())) { var cityName = UsCityStateZip.FinesseCityName(ca.City); var nodes = UsBanksXml.SelectNodes($"//com[@us-state='{ca.GetRegionAbbrev().ToUpper()}']"); if (nodes != null && nodes.Count > 0) { foreach (var node in nodes) { var elem = node as XmlElement; if (elem == null) { continue; } if (!elem.HasAttributes) { continue; } if (elem.GetAttribute("city") != cityName) { continue; } pickFromList.Add(elem); } } } if (!pickFromList.Any()) { var allNodes = UsBanksXml.SelectNodes("//com"); if (allNodes == null) { return(null); } foreach (var node in allNodes) { var elem = node as XmlElement; if (elem == null) { continue; } if (!elem.HasAttributes) { continue; } pickFromList.Add(elem); } } if (pickFromList.Any()) { bankXmlElem = pickFromList[Etx.RandomInteger(0, pickFromList.Count - 1)]; } return(bankXmlElem); }