public ActionResult CreateWishList(string code) { var username = User.Identity.Name; if (!string.IsNullOrEmpty(username)) { var user = db.Refugee.SingleOrDefault(u => u.AuthorityCode == username); string fullName = string.Concat(new string[] { user.RefugeeFName, " ", user.RefugeeLName }); ViewData.Add("FullName", fullName); } if (code == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Refugee refugee = db.Refugee.Where(a => a.AuthorityCode == code).FirstOrDefault(); if (refugee == null) { return(HttpNotFound()); } int id = refugee.RID; // GET: Wish_List/Create ViewBag.list = db.Wish_List.Where(a => a.RID == id); //Todo ViewBag.Item_ID = new SelectList(db.Item, "Item_ID", "Item_Name"); ViewBag.RID = new SelectList(db.Refugee, "RID", "RefugeeFName"); ViewBag.id = new SelectList(db.Refugee.Where(a => a.RID == id), "RID", "RefugeeFName"); ViewBag.rid = id; return(View()); }
public ActionResult ChangePassword([Bind(Include = "RID,AuthorityCode,RefugeeFName,RefugeeLName,Password,OldConfirmPassword,ConfirmNewPassword,NewPassword,Postcode,Email,Street,Suburb,State,Phone,Family_Description,Icon")] Refugee refugee) { newleavesdatabaseEntities1 db = new newleavesdatabaseEntities1(); if (refugee.OldConfirmPassword != null && refugee.NewPassword != null && refugee.NewPassword != null) { if (string.Compare(Crypto.Hash(refugee.OldConfirmPassword), refugee.Password) == 0) { if (ModelState.IsValid) { refugee.Password = refugee.NewPassword; refugee.Password = Crypto.Hash(refugee.Password); db.Entry(refugee).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("RefugeeDetailsAfter", new { code = User.Identity.Name })); } } else { ViewData["Non"] = "The old password didn't match"; return(View("ChangePassword", refugee)); } } else { ViewData["Non"] = "Please fill all the boxes before submit."; return(View("ChangePassword", refugee)); } return(View()); }
/// <summary> /// Removes an occupant, but does not specify the "available space" that this "house" posseses to the manager. /// </summary> /// <param name="_r">Occupant to remove.</param> public override void RemoveOccupant(Refugee _r) { if (occupants.Contains(_r)) { occupants.Remove(_r); } }
/// <summary> /// Removes specified occupant /// </summary> /// <param name="_r">Occupant to remove.</param> public virtual void RemoveOccupant(Refugee _r) { if (occupants.Contains(_r)) { occupants.Remove(_r); } }
public ActionResult DeleteConfirmed(int id) { Refugee refugee = db.Refugee.Find(id); db.Refugee.Remove(refugee); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "RID,RefugeeFName,RefugeeLName,AuthorityCode,Password,Street,Suburb,State,Email,Postcode,Phone,Family_Description,Icon")] Refugee refugee) { if (ModelState.IsValid) { db.Entry(refugee).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(refugee)); }
public ActionResult Create([Bind(Include = "RID,RefugeeFName,RefugeeLName,AuthorityCode,Password,Street,Suburb,State,Email,Postcode,Phone,Family_Description,Icon")] Refugee refugee) { if (ModelState.IsValid) { refugee.Password = Crypto.Hash(refugee.Password); db.Refugee.Add(refugee); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(refugee)); }
// GET: Refugees/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Refugee refugee = db.Refugee.Find(id); if (refugee == null) { return(HttpNotFound()); } return(View(refugee)); }
/// <summary> /// Removes an occupant, but does not specify the "available space" that this "house" posseses to the manager. /// </summary> /// <returns>Refugee removed</returns> public override Refugee RemoveOccupant() { if (GetOccupantCount() == 0) { Debug.LogError("No Occupants to remove"); return(null); } Refugee _r = occupants[0]; occupants.Remove(_r); _r.SetHouse(null); return(_r); }
public void NewHouseBuilt(House house) { houses.Add(house); if (house.GetType() == typeof(HomelessHouse)) { return; } AddBelowPrefOccupants(house.GetHashVal(), house); GameManager.GetInstance().AddHousing(house.GetMaxOccupancy()); // TODO: This needs to be replaced when refactoring UI to look better // If there are any homeless, fill this house as full as possible, // because even overcrowded housing is better than being homeless if (homeless.Count > 0) { while (homeless.Count > 0 && house.GetMaxOccupancy() > house.GetOccupantCount()) { Refugee _r = homeless.Dequeue(); homelessHouse.RemoveOccupant(_r); house.AddOccupant(_r); } } // if there's still any preferred space, take some people out of overcrowded houses while (house.GetPrefOccupancy() > house.GetOccupantCount()) { bool allHousingAtPreferredLevels = true; foreach (House h in houses) { // Take them out one by one so crowding levels lower uniformly across houses if (h.GetPrefOccupancy() < h.GetOccupantCount()) { house.AddOccupant(h.RemoveOccupant()); // See if we need to keep looping (so no infinite while loop) if (h.GetPrefOccupancy() < h.GetOccupantCount()) { allHousingAtPreferredLevels = false; } } } // Stop looping because even though this house isn't full, there are no other refugees in overcrowded houses if (allHousingAtPreferredLevels) { return; } } }
private IEnumerator ProcessAllRefugees() { while (true) { if (queue.Count == 0) { yield return(new WaitForTicks(1)); } else { Refugee current = queue.Dequeue(); current.SetNewDestination(lineStartPos); yield return(new WaitForTicks(timeToProcess)); current.SetNewDestination(finishedProcessingPos); HousingManager.GetInstance().GetBestHouse().AddOccupant(current); } } }
public ActionResult ChangePassword(string code) { var username = User.Identity.Name; if (!string.IsNullOrEmpty(username)) { var user = db.Refugee.SingleOrDefault(u => u.AuthorityCode == username); string fullName = string.Concat(new string[] { user.RefugeeFName, " ", user.RefugeeLName }); ViewData.Add("FullName", fullName); } if (code == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Refugee refugee = db.Refugee.SingleOrDefault(r => r.AuthorityCode == code); // User myUser = myDBContext.Users.SingleOrDefault(user => user.Username == username); return(View(refugee)); }
public ActionResult RefugeeModifyAccount(int?id) { var username = User.Identity.Name; if (!string.IsNullOrEmpty(username)) { var user = db.Refugee.SingleOrDefault(u => u.AuthorityCode == username); string fullName = string.Concat(new string[] { user.RefugeeFName, " ", user.RefugeeLName }); ViewData.Add("FullName", fullName); } if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Refugee refugee = db.Refugee.Find(id); if (refugee == null) { return(HttpNotFound()); } return(View(refugee)); }
//Get refugee by email public ActionResult Details(String email) { if (email == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Refugee refugee = db.Refugee.SingleOrDefault(r => r.Email == email); // User myUser = myDBContext.Users.SingleOrDefault(user => user.Username == username); if (refugee == null) { return(HttpNotFound()); } //Store your email (in the TempData) //TempData["id"] = refugee.RID; //Store your Student (in the Session) //Session["Student"] = oStudent; //return RedirectToAction("Details", "Refugees"); return(RedirectToAction("Details", "Refugees", new { id = refugee.RID })); // return View(refugee); }
/// <summary> /// Removes a refugee from this house. /// </summary> /// <returns>Refugee removed.</returns> public virtual Refugee RemoveOccupant() { if (GetOccupantCount() == 0) { Debug.LogError("No Occupants to remove"); return(null); } Refugee _r = occupants[0]; occupants.Remove(_r); _r.SetHouse(null); if (GetOccupantCount() < prefOccupancy) { HousingManager.GetInstance().AddBelowPrefOccupants(GetHashVal(), this); HousingManager.GetInstance().RemoveBelowMaxOccupants(GetHashVal()); } else if (GetOccupantCount() < maxOccupancy) { HousingManager.GetInstance().AddBelowMaxOccupants(GetHashVal(), this); } return(_r); }
/// <summary> /// Adds occupant _r into this house. /// </summary> /// <param name="_r">Refugee to add to this house.</param> public virtual void AddOccupant(Refugee _r) { if (maxOccupancy == GetOccupantCount()) { Debug.LogError(gameObject.name + " is already a full house."); return; } occupants.Add(_r); _r.SetHouse(this); if (GetOccupantCount() < prefOccupancy) { HousingManager.GetInstance().AddBelowPrefOccupants(GetHashVal(), this); } else if (GetOccupantCount() < maxOccupancy) { HousingManager.GetInstance().RemoveBelowPrefOccupants(GetHashVal()); HousingManager.GetInstance().AddBelowMaxOccupants(GetHashVal(), this); } else { HousingManager.GetInstance().RemoveBelowMaxOccupants(GetHashVal()); } }
public ActionResult RefugeeDetailsAfter(String code) { var username = User.Identity.Name; if (!string.IsNullOrEmpty(username)) { var user = db.Refugee.SingleOrDefault(u => u.AuthorityCode == username); string fullName = string.Concat(new string[] { user.RefugeeFName, " ", user.RefugeeLName }); ViewData.Add("FullName", fullName); } if (code == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Refugee refugee = db.Refugee.SingleOrDefault(r => r.AuthorityCode == code); // User myUser = myDBContext.Users.SingleOrDefault(user => user.Username == username); if (refugee == null) { return(HttpNotFound()); } ViewData["Title1"] = "Change Password Successfully"; return(View("RefugeeDetails", refugee)); }
// GET: Donations/Create //button name: Donate public ActionResult Create(int id) { if (!User.Identity.Name.Contains("@")) { return(RedirectToAction("Login", "DonorRegister")); } else { //get the login donor information and refugee infomation // write this imformation to donation table Wish_List wish = db.Wish_List.Find(id); Refugee refugee = wish.Refugee; String email = User.Identity.Name; Donor donor = db.Donor.SingleOrDefault(d => d.Email == email); //update the status record in wishlist table // wish.Status = "In processing"; // if (ModelState.IsValid) // { // db.Entry(wish).State = EntityState.Modified; // db.SaveChanges(); // //return RedirectToAction("Index"); /// } //jump to donor, rufugee check page ViewBag.wishlistid = wish.Wish_List_ID; ViewBag.wish = wish; ViewBag.Item_Name = wish.Item.Item_Name; //ViewBag.reugee = refugee; ViewBag.donor = donor; ViewBag.fullAddress = donor.Street + " " + donor.Suburb + " " + donor.State; ViewBag.DID = new SelectList(db.Donor, "DID", "FirstName"); ViewBag.Wish_List_ID = new SelectList(db.Wish_List, "Wish_List_ID", "Status"); return(View()); } }
public void AddRefugee(Refugee newRefugee) { queue.Enqueue(newRefugee); newRefugee.SetNewDestination(beforeProcessingPos + new Vector3(Random.Range(-10, 10), 0, Random.Range(-10, 10))); }
/// <summary> /// Adds an occupant, but does not specify the "available space" that this "house" posseses to the manager. /// </summary> /// <param name="_r">Refugee to add.</param> public override void AddOccupant(Refugee _r) { occupants.Add(_r); _r.SetHouse(this); }
public void EnqueueHomeless(Refugee _r) { homeless.Enqueue(_r); }