public void Save(Locality obj) { if (obj.Id == 0) context.Entry(obj).State = System.Data.Entity.EntityState.Added; else context.Entry(obj).State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); }
/// <summary> /// Замена населенного пункта на столицу /// </summary> /// <param name="localityToChange"></param> /// <returns></returns> private Locality GetCapital(Locality localityToChange) { if (localityToChange.IsCountryCapital) { return(null); } //меняем столицу ФО на столицу страны if (localityToChange.IsDistrictCapital) { return(_localities.FirstOrDefault(locality => localityToChange.Region.District.Country.Id == locality.Region.District.Country.Id && locality.IsCountryCapital)); } //меняем столицу региона на столицу ФО if (localityToChange.IsRegionCapital) { return(_localities.FirstOrDefault(locality => localityToChange.Region.District.Id == locality.Region.District.Id && locality.IsDistrictCapital)); } //меняем населенный пункт на столицу региона return(_localities.FirstOrDefault(locality => localityToChange.Region.Id == locality.Region.Id && locality.IsRegionCapital)); }
public IActionResult Update(long id, [FromBody] Locality item) { Console.WriteLine("{0}, {1}", id, item.Id); if (item == null || item.Id != id) { return(BadRequest()); } var locality = context.Localities.FirstOrDefault(t => t.Id == id); if (locality == null) { return(NotFound()); } locality.Name = item.Name; locality.AreaId = item.AreaId; locality.Population = item.Population; locality.Type = locality.Type; context.Localities.Update(locality); context.SaveChanges(); return(new NoContentResult()); }
// Update is called once per frame void Update() { // If online stuff is disabled and somehow we are on internet scores switch back to local. if (SaveManager.save != null && !Options.Networking) { locality = Locality.Local; } // If the selected level has changed then load the recordings for that level. if (oldLevel != LevelSelectGUI.currentLevel || oldPlanet != LevelSelectGUI.currentPlanet) { if (LevelSelectGUI.currentLevel != null) { oldLevel = LevelSelectGUI.currentLevel; oldPlanet = LevelSelectGUI.currentPlanet; // Reload the replays LoadReplays(); } } }
public bool EditLocality(Locality pre, Locality post) { if (user.isAdmin()) { using (var ctx = new SocializRContext()) { ctx.Locality.Update(pre); if (pre.Name != post.Name) { pre.Name = post.Name; } if (pre.CountyId != post.CountyId) { pre.CountyId = post.CountyId; pre.County = post.County; } ctx.Locality.Update(pre); ctx.SaveChanges(); return(true); } } return(false); }
public override void Parse(string arg) { if (arg.Equals("-a", StringComparison.InvariantCultureIgnoreCase) || arg.Equals("--all", StringComparison.InvariantCultureIgnoreCase)) { locality = Locality.All; } else if (arg.Equals("-l", StringComparison.InvariantCultureIgnoreCase) || arg.Equals("--local", StringComparison.InvariantCultureIgnoreCase)) { locality = Locality.Local; } else if (arg.Equals("-r", StringComparison.InvariantCultureIgnoreCase) || arg.Equals("--roaming", StringComparison.InvariantCultureIgnoreCase)) { locality = Locality.Roaming; } else if (arg.Equals("-t", StringComparison.InvariantCultureIgnoreCase) || arg.Equals("--temporary", StringComparison.InvariantCultureIgnoreCase)) { locality = Locality.Temporary; } else { base.Parse(arg); } }
public IActionResult Update(long id, [FromBody] Locality item) { if (item == null || item.Id != id) { return(BadRequest()); } var locality = _context.Localities.FirstOrDefault(t => t.Id == id); if (locality == null) { return(NotFound()); } locality.CountryId = item.CountryId; locality.Name = item.Name; locality.LocalityTypeId = item.LocalityTypeId; locality.RegionId = item.RegionId; _context.Localities.Update(locality); _context.SaveChanges(); return(new NoContentResult()); }
public ActionResult Edit(Locality obj) { if (ModelState.IsValid) { if (!dataManager.Localities.GetAll() .Where(m => m.DistrictId == obj.DistrictId) .Any(o => o.Name == obj.Name)) { var objFromDb = dataManager.Localities.Get(obj.Id); objFromDb.Name = obj.Name; objFromDb.DistrictId = obj.DistrictId; dataManager.Localities.Save(objFromDb); return(RedirectToAction("Show", new { Id = obj.Id })); } else { ModelState.AddModelError("Name", "Нас. пункт с названием \"" + obj.Name + "\" уже существует!"); return(View(obj)); } } return(View(obj)); }
private void InsertLocalities() { ReportStart(_cache.Locality, "Locality"); var currentProgress = 0; foreach (var item in _cache.Locality) { var entity = new Entity.tLocality() { LocalityId = item.Id, Locality = item.Description, }; _context.tLocality.Add(entity); Locality.Add(item, entity); IncreaseCurrent(ref currentProgress); } ReportFinish(); }
protected IEnumerator MoveToConquer(Locality target) { float minDist = 1f; moveTarget = target.transform.position; movement.MoveTo(moveTarget.Value); while (true) { if (moveTarget != null) { Vector3 vDist = moveTarget.Value - transform.position; vDist.y = 0; if (vDist.magnitude < minDist) { moveTarget = null; movement.Stop(); StartCoroutine(Conquer(target)); yield break; } } yield return(null); } }
public override int GetHashCode() { int hash = 1; if (locality_ != null) { hash ^= Locality.GetHashCode(); } hash ^= lbEndpoints_.GetHashCode(); if (loadBalancingWeight_ != null) { hash ^= LoadBalancingWeight.GetHashCode(); } if (Priority != 0) { hash ^= Priority.GetHashCode(); } if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
public override string ToString() { var parts = new List <string>(); if (Addressee != null && !string.IsNullOrWhiteSpace(Addressee.ToString())) { parts.Add(Addressee.ToString()); } if (StreetAddress != null && !string.IsNullOrWhiteSpace(StreetAddress.ToString())) { parts.Add(StreetAddress.ToString()); } if (Locality != null && !string.IsNullOrWhiteSpace(Locality.ToString())) { parts.Add(Locality.ToString()); } if (AdministrativeRegion != null && !string.IsNullOrWhiteSpace(AdministrativeRegion.ToString())) { parts.Add(AdministrativeRegion.ToString()); } if (PostalCode != null && !string.IsNullOrWhiteSpace(PostalCode.ToString())) { parts.Add(PostalCode.ToString()); } if (Country != null && !string.IsNullOrWhiteSpace(Country.ToString())) { parts.Add(Country.ToString()); } return(string.Join(", ", parts)); }
public LocationTest() { t1 = new Location { Geohash = "1", Address = "food" }; t2 = new Location { Geohash = "2", Address = "meat" }; t3 = new Location { Geohash = "3", Address = "drink" }; t4 = new Location { Geohash = "4", Address = "meal" }; t5 = new Location { Geohash = "5", Address = "dog" }; locality1 = new Locality { Name = "Hobart", Postcode = "7000" }; s1 = new State { Name = "Tasmania", Country = "Australia" }; }
public NewHousingViewModel(INavigationService navigationService) { NewHousing = new HousingPost { // HostID = ViewModelLocator.ConnectedUser.ID, Number = null, PostBox = 0, Street = null, ZipCode = 0, City = null, Wifi = false, Kitchen = false, Office = false, Shower = false, Toilet = false, SpaceLocalization = null, Description = null, Pictures = null, StartDate = DateTime.Now, EndDate = DateTime.Now, BedType = 1 }; StartDay = new DateTimeOffset(DateTime.Now); EndDay = new DateTimeOffset(DateTime.Now); StartTime = new TimeSpan(14, 00, 00); EndTime = new TimeSpan(14, 00, 00); _bedTypeCollection = ViewModelLocator.BedsList; _localitiesCollection = ViewModelLocator.LocalitiesList; _selectedBedType = _bedTypeCollection[0]; _selectedLocality = _localitiesCollection[0]; }
public void MergeFrom(DeviceAttributes other) { if (other == null) { return; } if (other.Name.Length != 0) { Name = other.Name; } if (other.DeviceType.Length != 0) { DeviceType = other.DeviceType; } if (other.MemoryLimit != 0L) { MemoryLimit = other.MemoryLimit; } if (other.locality_ != null) { if (locality_ == null) { locality_ = new global::Tensorflow.DeviceLocality(); } Locality.MergeFrom(other.Locality); } if (other.Incarnation != 0UL) { Incarnation = other.Incarnation; } if (other.PhysicalDeviceDesc.Length != 0) { PhysicalDeviceDesc = other.PhysicalDeviceDesc; } _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); }
private uint FileSystemAddFolder(string path, Locality locality, string source) { PrintLineFormat("Scanning {0}", locality.ToString()); string parent = Path.GetDirectoryName(source); string saveCurrentDirectory = Directory.GetCurrentDirectory(); Directory.SetCurrentDirectory(parent); uint count = 0; string sourceRoot = Path.GetFileName(source); foreach (var fse in Directory.EnumerateFileSystemEntries(sourceRoot, "*", SearchOption.AllDirectories)) { string targetFilename = Path.Combine(path, fse); ShowProgressAddingFileSystemEntry(fse); if ((File.GetAttributes(fse) & System.IO.FileAttributes.Directory) != 0) { Directory.CreateDirectory(targetFilename); } else { File.Copy(fse, targetFilename); } ++count; } Directory.SetCurrentDirectory(saveCurrentDirectory); if (this.displayLevel < DisplayLevel.Verbose && count > 0) { PrintLine(); } return(count); }
public void CreateAddress() { Address aTest = new Address(); aTest.Address1 = "blah"; aTest.Address2 = "blah2"; aTest.Country = "United States"; aTest.PostalCode = "84101"; Locality addressCity = new Locality(); addressCity.LocalityName = "Salt Lake City"; addressCity.LocalityType = TerritoryType.City; Locality addressState = new Locality(); addressState.LocalityName = "Utah"; addressState.LocalityType = TerritoryType.State; aTest.Localities.Add(addressState); Assert.IsNotNull(aTest); Assert.IsTrue(aTest.Localities.Count > 0); }
public void removeLocality(String locality) { Locality.Remove(locality); }
public void addLocality(String locality) { Locality.Add(locality); }
public IList <PostalCode> GetPostalCodes(Locality locality) { throw new System.NotImplementedException(); }
public void UpdateLocality(Locality locality) { }
// Draw the highscores. void OnGUI() { if (LevelSelectGUI.menuState != LevelSelectGUI.MenuState.LEVEL_SELECT) enable = false; if (!enable) { GUIController.HideText("ScoreTypeName"); return; } // Set skin and store old skin GUISkin oldSkin = GUI.skin; GUI.skin = Screen.width > 1500 ? biggerSkin : guiSkin; // Find out whether or not a planet is selected if (LevelSelectGUI.currentPlanet == null || !enable) return; // Calculate the how large things need to be. float labelPosX = Screen.width / 20; float labelPosY = Screen.height / 20; float labelWidth = Screen.width - (Screen.width / 10); float labelHeight = (Screen.height / 12); float buttonX = labelPosX; float buttonY = labelPosY; float buttonWidth = (Screen.width / 6); float buttonHeight = labelHeight; float buttonScoreTypeX = labelPosX + buttonWidth; float buttonScoreTypeY = buttonY; float scrollPosX = labelPosX; float scrollPosY = buttonY + buttonHeight; float scrollWidth = labelWidth; float scrollHeight = (Screen.height / 2.0f); float playButtonX = scrollPosX; float playButtonY = scrollPosY + scrollHeight + 5; float playButtonWidth = scrollWidth; float playButtonHeight = scrollHeight / 4; // Update the mouse position if (InputManager.currentPosition.x > labelPosX && InputManager.currentPosition.y > (Screen.height - (playButtonY + playButtonHeight))) { if (InputManager.held) { if ((lastMousePos - InputManager.currentPosition).y < 10.0f) scrolled.y -= (lastMousePos - InputManager.currentPosition).y; } } lastMousePos = InputManager.currentPosition; // Draw a texture at the back GUI.DrawTexture(new Rect(labelPosX, labelHeight + labelPosY, playButtonX + playButtonWidth - (Screen.width / 20), playButtonY + playButtonHeight - labelHeight - buttonY), BG); // Draw a label at the top of the menu. string label = (locality == Locality.Internet ? "Internet" : "Local") + " " + (scoreType == HighScores.ScoreType.Speed ? "Top Scores" : "Fastest Times"); GUIController.ShowText("ScoreTypeName", label); // Draw the play replay button if (GUI.Button(new Rect(playButtonX, playButtonY, playButtonWidth, playButtonHeight), "Play Replay")) { LevelSelectGUI.worldToShow = LevelSelectGUI.currentWorld; LevelSelectGUI.levelToShow = LevelSelectGUI.currentLevel.number; if (locality == Locality.Local && selectedIndex < recordings.Count) { GameRecorder.StartPlaybackFromMenu(recordings[selectedIndex]); } else { // Grab the recording from the net. if (scores != null) Networking.GetRecording(LoadRecordingFromInternet, scores[selectedIndex].id); } if (selectedIndex < recordings.Count) GameRecorder.StartPlaybackFromMenu(recordings[selectedIndex]); } // Draw the button to switch from local to internet // and vice versa. string buttonText = ""; switch (locality) { case Locality.Local: buttonText = "Internet Scores"; break; case Locality.Internet: buttonText = "Local Scores"; break; default: buttonText = "Wut"; break; } if (Options.Networking) { if (GUI.Button(new Rect(buttonX, buttonY, buttonWidth, buttonHeight), buttonText)) { if (locality == Locality.Local) locality = Locality.Internet; else locality = Locality.Local; // Refresh the scores LoadReplays(); } } // Button to switch score type. string scoreTypeText = ""; switch (scoreType) { case HighScores.ScoreType.Speed: scoreTypeText = "View Fastest Times"; break; case HighScores.ScoreType.Time: scoreTypeText = "View Highest Scores"; break; default: scoreTypeText = "Wut"; break; } if (GUI.Button(new Rect(buttonScoreTypeX, buttonScoreTypeY, buttonWidth, buttonHeight), scoreTypeText)) { if (scoreType == HighScores.ScoreType.Speed) scoreType = HighScores.ScoreType.Time; else scoreType = HighScores.ScoreType.Speed; // Refresh the scores LoadReplays(); } // The scrolling menu stuff GUILayout.BeginArea(new Rect(scrollPosX, scrollPosY, scrollWidth, scrollHeight)); scrolled = GUILayout.BeginScrollView(scrolled); if (names != null) selectedIndex = GUILayout.SelectionGrid(selectedIndex, names, 1); GUILayout.EndScrollView(); GUILayout.EndArea(); // Restore old skin GUI.skin = oldSkin; }
public LocalityViewModel(Locality locality) { Locality = locality; }
public ActionResult <int> CreateLocality(Locality locality) { int numberOfAffectedRows = _repository.CreateLocality(locality); return(Ok(numberOfAffectedRows)); }
public short Distance(Locality p, Locality q) { return(Distance(GetLocalityPoint(p.Id), GetLocalityPoint(q.Id))); }
public PushpinViewModel(Locality locality, string label) { this.locality = locality; this.label = label; }
private void TryAddDisc(IDriveInfo drive, Locality locality, Cursor previousCursor) { Cursor = Cursors.WaitCursor; Application.DoEvents(); string discId; try { discId = DvdDiscIdCalculator.Calculate(drive.DriveLetter); } catch { UIServices.ShowMessageBox(string.Format(MessageBoxTexts.DriveNotReady, drive.DriveLetter), MessageBoxTexts.WarningHeader, UI.Buttons.OK, UI.Icon.Warning); return; } var suffix = locality.ID > 0 ? $".{locality.ID}" : string.Empty; var profileId = $"I{discId}{suffix}"; var profileIds = ((object[])Api.GetAllProfileIDs()).Cast <string>().ToList(); var existingProfileId = profileIds.FirstOrDefault(id => profileId.Equals(id)); var formattedDiscId = FormatDiscId(discId); if (!string.IsNullOrEmpty(existingProfileId)) { Api.SelectDVDByProfileID(profileId); Cursor = previousCursor; UIServices.ShowMessageBox(string.Format(MessageBoxTexts.ProfileAlreadyExists, formattedDiscId, locality.Description), MessageBoxTexts.WarningHeader, UI.Buttons.OK, UI.Icon.Warning); } else { if (_allProfiles == null) { _allProfiles = profileIds.Select(id => { Api.DVDByProfileID(out var profile, id, 0, 0); return(profile); }).ToList(); } DefaultValues.DownloadProfile = UpdateFromOnlineDatabaseCheckBox.Checked; var parentProfile = AddAsChildCheckBox.Checked ? _parentProfile : null; Cursor = previousCursor; using (var form = new AddDiscForm(_serviceProvider, locality, profileId, discId, drive, parentProfile, _allProfiles, formattedDiscId)) { if (form.ShowDialog() == DialogResult.OK) { profileIds.Add(profileId); _allProfiles.Add(form.NewProfile); } } } }
public void Use(Agent agent, Globe globe, IDice dice) { globe.LocalitiesCells.TryGetValue(agent.Location, out var currentLocality); var highestBranchs = agent.Skills .Where(x => /*x.Key != BranchType.Politics &&*/ x.Value >= 1) .OrderBy(x => x.Value); if (!highestBranchs.Any()) { return; } var firstBranch = highestBranchs.First(); // Обнаружение свободных узлов для размещения населённого пункта. // Свободные узлы ишутся от текущей локации агента. TerrainCell freeLocaltion = null; var nextCoords = HexHelper.GetOffsetClockwise(); var agentCubeCoords = HexHelper.ConvertToCube(agent.Location.Coords.X, agent.Location.Coords.Y); for (var i = 0; i < nextCoords.Length; i++) { var scanCubeCoords = agentCubeCoords + nextCoords[i]; var scanOffsetCoords = HexHelper.ConvertToOffset(scanCubeCoords); var freeX = scanOffsetCoords.X; var freeY = scanOffsetCoords.Y; // Убеждаемся, что проверяемый узел находится в границах мира. var isPointInside = IsPointInsideWorld(freeX, freeY, globe.Terrain); if (!isPointInside) { continue; } // Проверка, есть ли в найденной локации населённые пункты. var freeLocaltion1 = globe.Terrain[freeX][freeY]; if (!globe.LocalitiesCells.TryGetValue(freeLocaltion1, out var freeCheckLocality)) { freeLocaltion = globe.Terrain[freeX][freeY]; } } if (freeLocaltion != null) { // Свободный узел был найден. // Тогда создаём здесь населённый пункт с доминирующей специаьностью агента. // Популяция нового нас.пункта минимальна. // Одна единица популяци из текущего нас.пункта снимается. // Считается, что часть жителей мигрировали для начала строительства нового нас.пункта. var localityName = globe.GetLocalityName(dice); var createdLocality = new Locality { Name = localityName, Branches = new Dictionary <BranchType, int> { { firstBranch.Key, 1 } }, Cell = freeLocaltion, Population = 1, Owner = currentLocality.Owner }; currentLocality.Population--; globe.Localities.Add(createdLocality); globe.LocalitiesCells[freeLocaltion] = createdLocality; globe.ScanResult.Free.Remove(freeLocaltion); } else { // Если не удалось найти свободный узел, // то агент перемещается в произвольный населённый пункт своего государства. TransportHelper.TransportAgentToRandomLocality(globe, dice, agent, currentLocality); } }
public ActionResult <int> UpdateLocality(int id, Locality locality) { int numberOfAffectedRows = _repository.UpdateLocality(id, locality); return(Ok(numberOfAffectedRows)); }
// Update is called once per frame void Update() { // If online stuff is disabled and somehow we are on internet scores switch back to local. if (SaveManager.save != null && !Options.Networking) locality = Locality.Local; // If the selected level has changed then load the recordings for that level. if (oldLevel != LevelSelectGUI.currentLevel || oldPlanet != LevelSelectGUI.currentPlanet) { if (LevelSelectGUI.currentLevel != null) { oldLevel = LevelSelectGUI.currentLevel; oldPlanet = LevelSelectGUI.currentPlanet; // Reload the replays LoadReplays(); } } }
public void DeleteLocality(Locality locality) { _regionalContext.LocalitiesGH.Remove(locality); }
public void EnterLocalitySite(string district) { Locality.Clear(); Locality.SendKeys(district); }
/// <summary> /// Выполняет перемещение агента в произвольный нас.пункт текущего государства, если это возможно. /// </summary> /// <param name="globe"> Мир. </param> /// <param name="dice"> Сервис случайностей. </param> /// <param name="agent"> Агент для перемещения. </param> /// <param name="currentLocality"> Текущая позиция агента. </param> /// <returns> Возвращает true в случае успешного перемещения. Иначе - false. </returns> /// <remarks> /// Агент перемещается, если найден подходящий нас. пункт. Иначе остаётся в текущем. /// </remarks> public static bool TransportAgentToRandomLocality(Globe globe, IDice dice, Agent agent, Locality currentLocality) { var targetLocality = RollTargetLocality(globe.Localities, dice, agent.Realm, currentLocality); if (targetLocality == null) { return(false); } if (currentLocality != null) { CacheHelper.RemoveAgentFromCell(globe.AgentCells, agent.Location, agent); } agent.Location = targetLocality.Cell; CacheHelper.AddAgentToCell(globe.AgentCells, agent.Location, agent); return(true); }
/// <summary> /// This Function is used to Delete previously added Locality from database and is performed by SuperAdmin Only. /// </summary> public static bool Delete(Locality info) { return(LocalityDA.Delete(info)); }