protected override void DidAddHome(HMHome home) { Homes.Add(home); SortHomes(); var newHomeIndex = Homes.IndexOf(home); if (newHomeIndex < 0) { return; } var indexPath = NSIndexPath.FromRowSection(newHomeIndex, (int)HomeListSection.Homes); var primaryIndexPath = NSIndexPath.FromRowSection(newHomeIndex, (int)HomeListSection.PrimaryHome); TableView.BeginUpdates(); if (Homes.Count == 1) { TableView.ReloadRows(new [] { primaryIndexPath }, UITableViewRowAnimation.Fade); } else { TableView.InsertRows(new [] { primaryIndexPath }, UITableViewRowAnimation.Automatic); } TableView.InsertRows(new [] { indexPath }, UITableViewRowAnimation.Automatic); TableView.EndUpdates(); }
// GET: Homes/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Homes homes = db.Homes.Find(id); if (homes == null) { return(HttpNotFound()); } if (User.IsInRole("Admin") || User.IsInRole("Employee")) { return(View(homes)); } else { string currentUserID = User.Identity.GetUserId(); var home = from h in db.Homes where h.OwnderId == currentUserID select h; return(View(home.FirstOrDefault())); } }
void Build() { MeshCollider meshCollider = GetComponent <MeshCollider>(); Homes home = GetComponent <Homes>(); WorkPlace workPlace = GetComponent <WorkPlace>(); rend.material = finishedMaterial; GameController.Instance.displayText.text = ""; if (meshCollider) { meshCollider.isTrigger = false; meshCollider.convex = false; } if (home) { home.enabled = true; } if (workPlace) { workPlace.enabled = true; } gameObject.layer = 0; Destroy(this); }
public async Task <ActionResult <Homes> > PostHomes(Homes homes) { _context.Homes.Add(homes); await _context.SaveChangesAsync(); return(CreatedAtAction("GetHomes", new { id = homes.HomeId }, homes)); }
public void Clear() { lock (Dwellers) Dwellers.Clear(); Homes.Clear(); Cafes.Clear(); Workplaces.Clear(); }
/// <summary> /// Переключение света в конкретном доме /// </summary> public void SwitchLightInHouse(int id, bool isOnLight) { if (CityPower < 100 || CityPower >= 25) { Homes.Find(x => x.Id == id).IsOnLight = isOnLight; } }
public async Task <IActionResult> PutHomes(int id, Homes homes) { if (id != homes.HomeId) { return(BadRequest()); } _context.Entry(homes).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!HomesExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> Edit(int id, [Bind("HomeNo,HomeName,HometypeCode,HomeAddress,HomePostcode,HomeTel")] Homes homes) { if (id != homes.HomeNo) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(homes); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!HomesExists(homes.HomeNo)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["HometypeCode"] = new SelectList(_context.Hometypes, "HometypeCode", "HometypeCode", homes.HometypeCode); return(View(homes)); }
// Removes a home from the List and updates the view. protected override void DidRemoveHome(HMHome home) { var index = Homes.IndexOf(home); if (index < 0) { return; } var indexPath = NSIndexPath.FromRowSection(index, (int)HomeListSection.Homes); Homes.RemoveAt(index); var primaryIndexPath = NSIndexPath.FromRowSection(index, (int)HomeListSection.PrimaryHome); // If there aren't any homes, we still want one cell to display 'No Homes'. // Just reload. TableView.BeginUpdates(); if (Homes.Count == 0) { TableView.ReloadRows(new [] { primaryIndexPath }, UITableViewRowAnimation.Fade); } else { TableView.DeleteRows(new [] { primaryIndexPath }, UITableViewRowAnimation.Automatic); } TableView.DeleteRows(new [] { indexPath }, UITableViewRowAnimation.Automatic); TableView.EndUpdates(); }
public ActionResult DeleteConfirmed(int id) { Homes homes = db.Homes.Find(id); db.Homes.Remove(homes); db.SaveChanges(); return(RedirectToAction("Index")); }
public AddHomeVM() { var conn = new ConnectionDB(); typeList = conn.TypeOfHome.ToList(); addedItem = new Homes(); addedProterty = new Property(); }
protected virtual void HomeDidUpdateName(HMHome home) { var homeIndex = Homes.IndexOf(home); if (homeIndex >= 0) { var indexPath = NSIndexPath.FromRowSection(homeIndex, 0); TableView.ReloadRows(new [] { indexPath }, UITableViewRowAnimation.Automatic); } }
public void Simulate(int start, int end) { for (int i = start; i <= end; i++) { //Console.WriteLine(); Homes.ForEach(h => h.CurrTime = i); Assigner.Assign(this.Homes); PrintResult(); } }
public void PrintResult() { if (Config.PrintDetailOfEachHome) { Homes.ForEach(h => { Console.WriteLine("AvailableSupply/Supplied = {0:F4}/{1:F4}, Required/Assigned = {2:F4}/{3:F4}, Reputation = {4:F4}, Cost = {5:F4} ", h.OriginEnergySupply, h.CurrSuppliedEnergy, h.OriginEnergyDemand, h.CurrAcquiredEnergy, h.Reputation, h.CurrEnergyCost); }); } }
public string GetUniqueHomeName() { int num = 1; while (Homes.Exists(x => x.Name.Equals(DefaultHomeName + num, StringComparison.OrdinalIgnoreCase))) { num++; } return(DefaultHomeName + num); }
public ActionResult Edit([Bind(Include = "HomeId,HomeName,Address,City,State,ZipCode,OwnderId,HomePhoto,SpecialNotes,IsActive,DateAdded")] Homes homes, HttpPostedFileBase homePhoto) { if (ModelState.IsValid) { #region File Upload if (homePhoto != null) { string file = homePhoto.FileName; //we need to make sure they are actually uploading an appropriate file type string ext = file.Substring(file.LastIndexOf('.')); string[] goodExts = { ".jpeg", ".jpg", ".png", ".gif" }; //check that the uploaded file is in our list of good file extensions if (goodExts.Contains(ext)) { //if valid ext, check file size <= 4mb (max by default from ASP.net) if (homePhoto.ContentLength <= 52428800) // specifying in bytes how big file can be { //create a new file name using a guid - a lot of users probably have images with the same names so we change it from what the user had to a guid Globally Unique Identifier file = Guid.NewGuid() + ext; #region Resize Image string savePath = Server.MapPath("~/Content/assets/img/Uploads/"); //taking the contents of this file and creatign a stream of bytes, http file base type is becmonig a stream of bytes into a type of image. this conversion has to take place for us to be able to resize the image Image convertedImage = Image.FromStream(homePhoto.InputStream); int maxImageSize = 500; int maxThumbSize = 100; //if you allowed image uploads for magazine and books - you would need to repeat that code - that's why the image service code is in an imageservice area UploadUtility.ResizeImage(savePath, file, convertedImage, maxImageSize, maxThumbSize); //saves image onto server - but doesn't update db need to make sure to update what is stored in the db #endregion if (homes.HomePhoto != null && homes.HomePhoto != "noimage.png") { string path = Server.MapPath("~/Content/assets/img/Uploads/"); UploadUtility.Delete(path, homes.HomePhoto); } } } homes.HomePhoto = file; } #endregion db.Entry(homes).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.OwnderId = new SelectList(db.UserDetails, "UserId", "CompanyName", homes.OwnderId); return(View(homes)); }
// Regenerates the list of homes using list provided by the home manager. // The list is then sorted and the view is reloaded. void ResetHomeList() { var h = HomeManager.Homes; Array.Sort(h, CompareHomes); Homes.Clear(); Homes.AddRange(h); TableView.ReloadData(); }
protected virtual void DidAddHome(HMHome home) { Homes.Add(home); SortHomes(); var newHomeIndex = Homes.IndexOf(home); var indexPathOfNewHome = NSIndexPath.FromRowSection(newHomeIndex, 0); TableView.InsertRows(new [] { indexPathOfNewHome }, UITableViewRowAnimation.Automatic); }
public void Update(Homes model) { var home = _ctx.home.FirstOrDefault(); home.headerTitolo = model.headerTitolo; home.headerTesto = model.headerTesto; home.headerImageId = model.headerImageId; home.newsletterImageId = model.newsletterImageId; _ctx.SaveChanges(); }
public async Task <IActionResult> Create([Bind("HomeNo,HomeName,HometypeCode,HomeAddress,HomePostcode,HomeTel")] Homes homes) { if (ModelState.IsValid) { _context.Add(homes); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["HometypeCode"] = new SelectList(_context.Hometypes, "HometypeCode", "HometypeCode", homes.HometypeCode); return(View(homes)); }
public async Task <IActionResult> Edit(int id, [Bind("HomeId,PublishDate,Type,Street,City,County,PostalCode,District,AppartmentNumber,Society,Floor,Elevator,Dop,Price,Bidding,HomeType,Tow,LivingArea,BiArea,GardenArea,BuildningSystem,Renovations,OtherBuildnings,LivingSpaceComment,Parking,TvInternet,HeatVentilation,BuildningYear,MounthlyFee,PartOfSociety,PawnBroking,AboutSociety,CommonAreas,TransactionFee,TransactionFeePaidBy,OperationCost,TypeCode,TaxValue,TaxValueProperty,TaxValueLand,TaxYear,PawnLetters,Heating,PowerComsumption,EnergyCosts,NumberOfOccupants,WaterAndSewedge,Cleaning,Insurance,InsuranceComment,EnergyDeclaration,EnergyPerfomance,EnergyClass,SpecificEnergyUsage,DeclarationDate,Inspector,SummaryHeading,Summary,OtherRightsAndLiabilities,Room, BrokerId")] Homes homes, string ImageText2, bool HeroImage2, int Brokers, HomesCreateViewModel model, string Information, string AboutSociety, string ImageAddress) { if (id != homes.HomeId) { return(NotFound()); } var getImages = _context.Image; // HERO IMAGE List <Image> HeroImages = new List <Image>(); foreach (var item in getImages) { if (item.HomeIds == id && item.HeroImage == true) { Image Herimgs = new Image() { ImageText = item.ImageText, ImageAdress = item.ImageAdress, ImageId = item.ImageId }; HeroImages.Add(Herimgs); } } ViewBag.HeroImages = HeroImages; ViewBag.BrokersId = new SelectList(_context.Broker, "BrokerId", "fullname"); if (ModelState.IsValid) { try { homes.deleted = false; homes.ImageAddress = ImageAddress; homes.AboutSociety = AboutSociety; homes.Information = Information; homes.BrokerId = Brokers; _context.Update(homes); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!HomesExists(homes.HomeId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(homes)); }
private async void OnReload(ReloadEventArgs e) { string path = Path.Combine(TShock.SavePath, "essentials.json"); Config = Config.Read(path); if (!File.Exists(path)) { Config.Write(path); } await Homes.ReloadAsync(); e.Player.SendSuccessMessage("[EssentialsPlus] Reloaded config and homes!"); }
public async Task <bool> GetUsers(string homeId) { Homes.Clear(); IMobileServiceTableQuery <HomeItem> homeQuery; homeQuery = HomeTable.HomeSyncTable.Where(p => p.HomeId == homeId); await HomeTable.Read(homeQuery); foreach (HomeItem HomeItem in HomeTable.HomeItems) { Homes.Add(Converters.HomeConverter.CreateFrom(HomeItem)); } return(true); }
public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Homes homes = db.Homes.Find(id); if (homes == null) { return(HttpNotFound()); } return(View(homes)); }
protected virtual void DidRemoveHome(HMHome home) { var removedHomeIndex = Homes.IndexOf(home); if (removedHomeIndex < 0) { return; } Homes.RemoveAt(removedHomeIndex); var indexPath = NSIndexPath.FromRowSection(removedHomeIndex, 0); TableView.DeleteRows(new [] { indexPath }, UITableViewRowAnimation.Automatic); }
void Start() { Homes home = GetComponent <Homes>(); WorkPlace workPlace = GetComponent <WorkPlace>(); if (home) { home.enabled = false; } if (workPlace) { workPlace.enabled = false; } }
public async Task <IActionResult> DeleteConfirmed(int id) { Homes homes = await _db.Homes.FindAsync(id); if (homes == null) { return(NotFound()); } else { _db.Homes.Remove(homes); await _db.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } }
// Finds the home in the Homes property and reloads the corresponding row. protected override void HomeDidUpdateName(HMHome home) { var index = Homes.IndexOf(home); if (index >= 0) { var listIndexPath = NSIndexPath.FromRowSection(index, (int)HomeListSection.Homes); var primaryIndexPath = NSIndexPath.FromRowSection(index, (int)HomeListSection.PrimaryHome); TableView.ReloadRows(new [] { listIndexPath, primaryIndexPath }, UITableViewRowAnimation.Automatic); } else { // Just reload the data since we don't know the index path. TableView.ReloadData(); } }
public void Insert(Homes model) { if (!_ctx.home.Any()) { _ctx.home.Add(model); } else { var home = _ctx.home.FirstOrDefault(); home.headerTitolo = model.headerTitolo; home.headerTesto = model.headerTesto; home.headerImageId = model.headerImageId; home.newsletterImageId = model.newsletterImageId; } _ctx.SaveChanges(); }
//private void CheckNewLocation(IDweller dweller, IBuilding obj) //{ // if (dweller.Position.Value == obj.Position.Value) // { // // yep // dweller.EnterBuilding(obj); // } //} public void Add(IBuilding building) { switch (building) { case IHome home: Homes.Add(home); break; case IWorkplace workplace: Workplaces.Add(workplace); break; case ICafe cafe: Cafes.Add(cafe); break; } }