/// <summary> /// Fill method for populating an entire collection of Residences /// </summary> public virtual void Fill(Residences residences) { // create the connection to use SqlConnection cnn = new SqlConnection(Residence.GetConnectionString()); try { using (cnn) { // open the connection cnn.Open(); // create an instance of the reader to fill. SqlDataReader datareader = SqlHelper.ExecuteReader(cnn, "gsp_SelectResidences"); // Send the collection and data to the object factory CreateObjectsFromData(residences, datareader); // close the connection cnn.Close(); } // nullify the connection cnn = null; } catch (SqlException sqlex) { throw sqlex; } }
public void AdministrationRule_Is_Not_Satisfied_When_Distance_To_SettlementCenter_Is_Greater_Than_40_Pixels() { IRoad road = _settlement.Roads.First(); var administration = new Administration() { Position = new Point(99, 51) }; var buildingPositions = road.GetPossibleBuildingPositions(new PossibleBuildingPositions(_settlement.Roads, _settlement.Fields)); buildingPositions.Remove(administration.Position); while (_settlement.Roads.SelectMany(g => g.Buildings).Count() < 120) { var position = buildingPositions[RandomProvider.Next(buildingPositions.Count)]; var building = new Residence { Position = position }; building.Road = road; _settlement.AddBuildingToRoad(road, building); } Assert.AreEqual(0, administration.CalculateFitness(new BuildingRule() { BuildingRoad = road, Fields = _settlement.Fields, Roads = _settlement.Roads, SettlementCenter = _settlement.SettlementCenter })); }
public WinResidences(Residence residence) { Residence = residence; InitializeComponent(); lblTitle.Content = "Verblijf editeren"; cmbKindOfResidence.IsEnabled = false; }
public static void AddressEntityToModel(Residence entity, ResidenceModel model) { model.Address.City = entity.Address.City; model.Address.Street = entity.Address.Street; model.Address.State = entity.Address.State; model.Address.PostalCode = entity.Address.PostalCode; }
public static void AddressModelToEntity(ResidenceModel model, Residence entity) { entity.Address.City = model.Address.City; entity.Address.Street = model.Address.Street; entity.Address.State = model.Address.State; entity.Address.PostalCode = model.Address.PostalCode; }
public static void BaseModelToEntity(ResidenceModel model, Residence entity) { entity.Id = model.Id; entity.Name = model.Name; entity.Price = model.Price; entity.UserId = model.UserId; }
public static ResidenceModel EntityToModel(Residence entity) { ResidenceModel model = new ResidenceModel() { ResidenceCategories = new List <CategoryModel>(), ResidenceCategoryId = new List <int>(), Images = new List <string>(), Address = new AddressModel(), UserDetails = new UserModel() }; if (entity != null) { BaseEntityToModel(entity, model); AddressEntityToModel(entity, model); ImagesEntityToModel(entity, model); CategoriesEntityToModel(entity, model); if (entity.User != null) { UserDetailsEntityToModel(entity, model); } } return(model); }
public static void ImagesEntityToModel(Residence entity, ResidenceModel model) { foreach (var item in entity.ResidenceImages) { model.Images.Add(item.ImageName); } }
public static void BaseEntityToModel(Residence entity, ResidenceModel model) { model.Id = entity.Id; model.Name = entity.Name; model.Price = entity.Price; model.UserId = entity.UserId; }
public IHttpActionResult PutResidence(Residence residence) { int id = residence.LocationID; if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != residence.LocationID) { return(BadRequest()); } db.Entry(residence).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!ResidenceExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
private static void LoadHouseNumbers() { Console.WriteLine("Enter Soure file path for houses"); String path = Console.ReadLine();; while (!File.Exists(path)) { Console.WriteLine("Please enter correct source file path"); path = Console.ReadLine();; Console.Read(); } string[] inputlines = File.ReadAllLines(path); String currentFolder = Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath); using (var unitOfWork = new UnitOfWork(new MahalluDBContext())) { for (int i = 0; i < inputlines.Length; i++) { string[] fields = inputlines[i].Split(','); Residence residence = new Residence(); residence.Number = fields[0].Trim(); foreach (var item in areas) { if (item.Id == Convert.ToInt32(fields[1].Trim())) { residence.Area = item.Name; } } residence.Name = fields[3].Trim(); unitOfWork.Residences.Add(residence); unitOfWork.Complete(); } } Console.WriteLine("Houses loaded successfully"); }
public String WhatCanIDoWithResidence(Residence residence) { if (!HttpContext.User.Identity.IsAuthenticated) { return("0"); } if (_userManager.GetUserId(_httpContextAccessor.HttpContext.User) == residence.OwnerId) { return("0"); } var agreements = _context.Agreements .Where(r => r.ResidenceId == residence.Id && r.ResidentId == _userManager.GetUserId(_httpContextAccessor.HttpContext.User)) .ToList(); if (agreements.Count() > 0) { return(agreements.First().Id.ToString()); } else { return("1"); } }
public void ChurchRule_Is_Not_Satisfied_When_There_Are_More_Less_100_ResidencesAnd_In_Neighborhood() { IRoad road = _settlement.Roads.First(); var church = new Church() { Position = new Point(50, 51) }; var buildingPositions = road.GetPossibleBuildingPositions(new PossibleBuildingPositions(_settlement.Roads, _settlement.Fields)); buildingPositions.Remove(church.Position); while (_settlement.Roads.SelectMany(g => g.Buildings).Count() < 10) { var position = buildingPositions[RandomProvider.Next(buildingPositions.Count)]; var building = new Residence { Position = position }; building.Road = road; _settlement.AddBuildingToRoad(road, building); } Assert.AreEqual(0, church.CalculateFitness(new BuildingRule() { BuildingRoad = road, Fields = _settlement.Fields, Roads = _settlement.Roads, SettlementCenter = _settlement.SettlementCenter })); }
public async Task <IActionResult> PutResidence([FromRoute] int id, [FromBody] Residence residence) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != residence.Id) { return(BadRequest()); } _context.Entry(residence).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ResidenceExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public void DoMigrate() { this.Database.Migrate(); var res = this.Residences.FirstOrDefault(x => x.Name == "Hesteria"); var runner = new Runner() { RunnerId = 1, FirstName = "Jenne", LastName = "Baeten", Residence = res, ResidenceId = res.ResidenceId }; if (this.Runners.Select(x => x).Where(x => x.RunnerId == 1).ToList().Count == 0) { this.Runners.Add(runner); this.SaveChanges(); } var residence = new Residence() { ResidenceId = 9, Name = "Justus Lipsius", Description = "" }; if (this.Residences.Select(x => x).Where(x => x.ResidenceId == 9).ToList().Count == 0) { this.Residences.Add(residence); this.SaveChanges(); } }
public static void HandleHousingReturn(WorldSession session, ClientHousingReturn _) { // housing return button will only be visible on other residence maps Residence residence = session.Player.ResidenceManager.Residence; if (session.Player.Map is not ResidenceMapInstance || session.Player.Map == residence?.Map) { throw new InvalidPacketValueException(); } // return player to correct residence instance ResidenceEntrance entrance = GlobalResidenceManager.Instance.GetResidenceEntrance(residence.PropertyInfoId); session.Player.Rotation = entrance.Rotation.ToEulerDegrees(); session.Player.TeleportTo(new MapPosition { Info = new MapInfo { Entry = entrance.Entry, InstanceId = residence.Parent?.Id ?? residence.Id }, Position = entrance.Position }); }
/// <summary> /// Create a new instance for <see cref="Player"/> with <see cref="MapInfo"/>. /// </summary> protected override ResidenceMapInstance CreateInstance(Player player, MapInfo info) { var sw = Stopwatch.StartNew(); Residence residence = null; if (info.InstanceId.HasValue) { // residence already exists but doesn't have an active instance residence = GlobalResidenceManager.Instance.GetResidence(info.InstanceId.Value); } // this shouldn't occur as a residence should always be created before adding a player to a residence map // here just in case that doesn't occur residence ??= GlobalResidenceManager.Instance.CreateResidence(player); var instance = new ResidenceMapInstance { InstanceId = residence.Id }; instance.Initialise(Entry); instance.Initialise(residence); sw.Stop(); if (sw.ElapsedMilliseconds > 10) { log.Warn($"Took {sw.ElapsedMilliseconds}ms to create instance for residence {residence.Id}!"); } return(instance); }
private void ExecuteDeleteResidence() { MessageBoxResult result = MessageBox.Show("Deleting Residence will delete all of the members also, \nAre you sure to delete", "Delete", MessageBoxButton.YesNo, MessageBoxImage.Warning); if (result == MessageBoxResult.Yes) { if (CurrentResidence != null) { using (var unitofWork = new UnitOfWork(new MahalluDBContext())) { List <ResidenceMember> members = new List <ResidenceMember>(unitofWork.ResidenceMembers.Find((x) => x.Residence_Id == CurrentResidence.Id)); unitofWork.ResidenceMembers.RemoveRange(members); Residence residence = unitofWork.Residences.Get(CurrentResidence.Id); unitofWork.Residences.Remove(residence); unitofWork.Complete(); ResidenceType residenceType = new ResidenceType { Residence = CurrentResidence, Operation = MahalluManager.Model.Common.Operation.Delete }; eventAggregator.GetEvent <PubSubEvent <ResidenceType> >().Publish(residenceType); ResidenceList.Remove(CurrentResidence); CurrentResidence = null; } } } }
public void SchoolRule_IsSatisfied__When_Ratio_Schools_Per_Residences_Is_Less_Than_1_To_100() { IRoad road = _settlement.Roads.First(); var school = new School() { Position = new Point(50, 51) }; var buildingPositions = road.GetPossibleBuildingPositions(new PossibleBuildingPositions(_settlement.Roads, _settlement.Fields)); buildingPositions.Remove(school.Position); while (_settlement.Roads.SelectMany(g => g.Buildings).Count() < 120) { var position = buildingPositions[RandomProvider.Next(buildingPositions.Count)]; var building = new Residence { Position = position }; building.Road = road; _settlement.AddBuildingToRoad(road, building); } Assert.AreEqual(5, school.CalculateFitness(new BuildingRule() { BuildingRoad = road, Fields = _settlement.Fields, Roads = _settlement.Roads, SettlementCenter = _settlement.SettlementCenter })); }
public Task TeleportSubCommandHandler(CommandContext context, string command, string[] parameters) { string name = parameters.Length == 0 ? context.Session.Player.Name : string.Join(" ", parameters); Residence residence = ResidenceManager.GetResidence(name).GetAwaiter().GetResult(); if (residence == null) { if (parameters.Length == 0) { residence = ResidenceManager.CreateResidence(context.Session.Player); } else { context.SendMessageAsync("A residence for that character doesn't exist!"); return(Task.CompletedTask); } } ResidenceEntrance entrance = ResidenceManager.GetResidenceEntrance(residence); context.Session.Player.TeleportTo(entrance.Entry, entrance.Position, 0u, residence.Id); return(Task.CompletedTask); }
public ActionResult DeleteConfirmed(int id) { Residence residence = Bs.GetTResidence(id); Bs.RemoveResidence(residence); return(RedirectToAction("Index")); }
public GameManager() { _menu = new Menu(); AddChild(_menu); environment = new Environment(); environment.OnAnimalClicked += onAnimalClicked; AddChild(environment); environment.x = 2300; //Animal residences residence = new Residence(); AddChild(residence); residence.x = 0; ///////////////////// _gameHUD = new HUD(); AddChild(_gameHUD); soundManager = new SoundManager(); AddChild(soundManager); scoreTracker = new ScoreTracker(); AddChild(scoreTracker); SetChildIndex(scoreTracker, 200000); }
/// <summary> /// The object factory for a particular data collection instance. /// </summary> public virtual void CreateObjectsFromData(Residences residences, System.Data.DataSet data) { // Do nothing if we have nothing if (data == null || data.Tables.Count == 0 || data.Tables[0].Rows.Count == 0) { return; } // Create a local variable for the new instance. Residence newobj = null; // Create a local variable for the data row instance. System.Data.DataRow dr = null; // Iterate through the table rows for (int i = 0; i < data.Tables[0].Rows.Count; i++) { // Get a reference to the data row dr = data.Tables[0].Rows[i]; // Create a new object instance newobj = System.Activator.CreateInstance(residences.ContainsType[0]) as Residence; // Let the instance set its own members newobj.SetMembers(ref dr); // Add the new object to the collection instance residences.Add(newobj); } }
public Person(Residence house, ushort houseFloor) : base(house.coordinates.x, house.coordinates.y, houseFloor) { this.home = house; this.routine = new Routine(house); ThingsPackage.add(this); }
public WinRental(Residence residence, Rentals rentals, Tenants tenants) { this.residence = residence; this.rentals = rentals; this.tenants = tenants; InitializeComponent(); }
public async Task <IActionResult> Edit(int id, Residence residence) { if (id != residence.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(residence); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ResidenceExists(residence.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["ResidenceBuildingId"] = new SelectList(_context.ResidenceBuildings, "Id", "Name", residence.ResidenceBuildingId); return(View(residence)); }
public void HandleHouseTeleport(ICommandContext context, [Parameter("", ParameterFlags.Optional)] string name) { Player target = context.GetTargetOrInvoker <Player>(); if (!target.CanTeleport()) { context.SendMessage("You have a pending teleport! Please wait to use this command."); return; } Residence residence = ResidenceManager.Instance.GetResidence(name ?? target.Name).GetAwaiter().GetResult(); if (residence == null) { if (name == null) { residence = ResidenceManager.Instance.CreateResidence(target); } else { context.SendMessage("A residence for that character doesn't exist!"); return; } } ResidenceEntrance entrance = ResidenceManager.Instance.GetResidenceEntrance(residence); target.TeleportTo(entrance.Entry, entrance.Position, 0u, residence.Id); }
private void Awake() { if (isTemplate) { template = this; } }
static void Main(string[] args) { MAS MamasAuction = new MAS(); SegevAgent segevG = new SegevAgent("SegevG Course", 7000); SegevAgent segevH = new SegevAgent("SegevH Course", 7000); SegevAgent segevI = new SegevAgent("SegevI Course", 7000); SegevAgent segevJ = new SegevAgent("SegevJ Course", 7000); Screen screen21 = new Screen("HP Elite 21", "21inch 4K Screen", 111); Screen screen24 = new Screen("BenQ 24", "24inch 4K Screen", 112); Office AppleTown = new Office("Apple Town", 1000, 50, 2500, true, true, true, 116, "Sillicon Valley, CA, USA"); Residence AssaHome = new Residence("Assa`s Home", 5, 12, 3, 2, 117, "Maagal HaShalom, Rishon Lezzion", true); Screen screen77 = new Screen("LG 77", "77inch 4K Screen", 115); MamasAuction.AddAgent(segevH); MamasAuction.AddAgent(segevG); MamasAuction.AddAgent(segevI); MamasAuction.AddAgent(segevJ); MamasAuction.CreateAuction(screen21, DateTime.Now.AddSeconds(3), 200, 5); MamasAuction.CreateAuction(screen24, DateTime.Now.AddSeconds(7), 300, 5); MamasAuction.CreateAuction(AppleTown, DateTime.Now.AddSeconds(20), 1200, 100); MamasAuction.CreateAuction(AssaHome, DateTime.Now.AddSeconds(20), 1000, 80); MamasAuction.CreateAuction(screen77, DateTime.Now.AddSeconds(30), 600, 10); MamasAuction.Start(); Console.Read(); }
private void Update_Overview() { City_Name_Text.text = City.Instance.Name; Cash_Text.text = Helper.Float_To_String(City.Instance.Cash, 1); Income_Text.text = Helper.Float_To_String(City.Instance.Cash_Delta, 2, true); Food_Current_Text.text = Helper.Float_To_String(City.Instance.Food_Current, 0); Food_Max_Text.text = Helper.Float_To_String(City.Instance.Food_Max, 0); Food_Produced_Text.text = Helper.Float_To_String(City.Instance.Food_Produced, 1, true); Food_Consumed_Text.text = Helper.Float_To_String(City.Instance.Food_Consumed, 1); Food_Delta_Text.text = Helper.Float_To_String(City.Instance.Food_Delta, 1, true); //Peasants Peasant_Happiness_Text.text = Helper.Float_To_String(City.Instance.Happiness[Building.Resident.Peasant] * 100.0f, 0); Peasant_Education_Text.text = "-"; Peasant_Health_Text.text = "WIP"; Peasant_Efficency_Text.text = string.Format("{0}%", Helper.Float_To_String(Residence.Get_Efficency(Building.Resident.Peasant) * 100.0f, 1)); //Citizens Citizen_Happiness_Text.text = Helper.Float_To_String(City.Instance.Happiness[Building.Resident.Citizen] * 100.0f, 0); Citizen_Education_Text.text = string.Format("{0}%", Helper.Float_To_String(City.Instance.Education[Building.Resident.Citizen] * 100.0f, 1)); Citizen_Health_Text.text = "WIP"; Citizen_Efficency_Text.text = string.Format("{0}%", Helper.Float_To_String(Residence.Get_Efficency(Building.Resident.Citizen) * 100.0f, 1)); //Nobles Noble_Happiness_Text.text = Helper.Float_To_String(City.Instance.Happiness[Building.Resident.Noble] * 100.0f, 0); Noble_Education_Text.text = string.Format("{0}%", Helper.Float_To_String(City.Instance.Education[Building.Resident.Noble] * 100.0f, 1)); Noble_Health_Text.text = "WIP"; Noble_Efficency_Text.text = string.Format("{0}%", Helper.Float_To_String(Residence.Get_Efficency(Building.Resident.Noble) * 100.0f, 1)); }
public void spawnInRoom(Residence room) { residence = room; room.deselect(); this.transform.position = room.transform.position; this.collisionBox.enabled = true; this.selfBody.isKinematic = false; }
// Use this for initialization void Awake() { originalPosition = Vector3.zero; residence = originalResidence; selected = false; spriteRender = this.GetComponent<SpriteRenderer>(); selfBody = this.GetComponent<Rigidbody2D>(); triggerBox = this.gameObject.GetComponent<Collider2D>(); sudokuManager = GameObject.FindObjectOfType<SudokuManager>(); }
// Use this for initialization void Awake() { this.transform.position += z_offset; originalPosition = Vector3.zero; residence = originalResidence; selected = false; spriteRender = this.GetComponent<SpriteRenderer>(); selfBody = this.GetComponent<Rigidbody2D>(); triggerBox = this.gameObject.GetComponent<Collider2D>(); }
void OnTriggerEnter2D(Collider2D col) { Residence apt = col.gameObject.GetComponent<Residence>(); if (apt != null) { //unhighlights other apts if they exist if (residence != null) { residence.deselect(); } //highlights the apt we entered if(apt != originalResidence) apt.select(); //sets the new residence residence = apt; } }
void OnTriggerExit2D(Collider2D col) { //Lets highlight the apt lol Residence apt = col.gameObject.GetComponent<Residence>(); if (residence == apt) { if (apt != null) { apt.deselect(); } residence = null; } }
public void spawnInRoom(Residence room) { this.transform.position = room.transform.position + z_offset; this.collisionBox.enabled = true; this.selfBody.isKinematic = false; }