private void Start() { //Reset running and finished since new level GameManager.instance.levelCompleted = false; GameManager.instance.running = false; GameManager.instance.coins = 0; startpo = transform.position; //Create the coderow for (int i = 0; i <= rowSize; i++) { Vector2 posR = new Vector2(transform.position.x + (i * 0.32f), transform.position.y); CodeBase basR = Instantiate(basePrefab, posR, Quaternion.identity); basR.transform.name = "CodeBase " + i; basR.transform.parent = transform; } //Create the codeblock givers for (int i = 0; i < codeGivers.Length; i++) { startpo = new Vector2(0.32f + (i * 0.48f), 0.64f); Giver giv = Instantiate(giverPrefab, startpo, Quaternion.identity); giv.transform.name = "Giver " + i; giv.GetComponent <SpriteRenderer>().sprite = codeGivers[i]; giv.count = codeGiverCounts[i]; //Text for codegiver Text givText = Instantiate(textPrefab, Vector2.zero, Quaternion.identity); givText.transform.SetParent(levelCanvas.transform, false); givText.rectTransform.localPosition = new Vector2(-576 + (i * 96), -465); giv.textUi = givText; } }
public override void PerformAction() { // check total debt var totalDebt = Giver.GivenTreatyClauses.OfType <TributeClause>().Where(c => c.Resource == Resource).Sum(c => c.Debt); // check max amount giveable var maxGiveable = Giver.StoredResources[Resource]; // how much to pay? int toPay; if (maxGiveable >= totalDebt) { toPay = Debt; } else { // pay proportional to debt to each empire toPay = Debt / totalDebt * maxGiveable; var unpaid = Debt - toPay; Giver.Log.Add(Receiver.CreateLogMessage("We were unable to fulfill our tribute obligations to the " + Receiver + ". We fell short by " + unpaid.ToUnitString(true) + " " + Resource.Name.ToLower() + ".", LogMessages.LogMessageType.Generic)); Receiver.Log.Add(Giver.CreateLogMessage("The " + Giver + "was unable to fulfill its tribute obligations. They fell short by " + unpaid.ToUnitString(true) + " " + Resource.Name.ToLower() + ".", LogMessages.LogMessageType.Generic)); } // transfer resources Giver.StoredResources[Resource] -= toPay; Receiver.StoredResources[Resource] += toPay; }
// GET: Givers/Details/5 public ActionResult Details(int?id) { try { if (Session["Role"].ToString() == "Admin") { goto CanDetails; } if (Session["GID"].ToString() == id.ToString()) { goto CanDetails; } else { return(RedirectToAction("MyAccount", "Users")); } CanDetails: if (id == null) { return(RedirectToAction("MyAccount", "Users")); } Giver giver = db.Givers.Find(id); if (giver == null) { return(HttpNotFound()); } return(View(giver)); } catch { return(RedirectToAction("login", "Users")); } }
public ActionResult CreateProfile([Bind(Include = "FirstName, LastName, Address, AboutMe")] Giver giver) { if (ModelState.IsValid) { db.Givers.Add(giver); db.SaveChanges(); return(RedirectToAction("ProfileComplete")); } return(View(giver)); //try //{ // ApplicationDbContext db = new ApplicationDbContext(); // Giver profile = new Giver(); // profile.FirstName = model.FirstName; // profile.LastName = model.LastName; // profile.Address = model.Address; // profile.AboutMe = model.AboutMe; // db.Givers.Add(profile); // db.SaveChanges(); //} //catch(Exception ex) //{ // throw ex; //} //return View(model); }
public ActionResult Edit([Bind(Include = "UserID,Email,Password,FirstName,LastName,Age,Gender,Role")] User user) { try { if (Session["ID"].ToString() == user.UserID.ToString() || Session["Role"].ToString() == "Admin") { if (ModelState.IsValid) { db.Entry(user).State = EntityState.Modified; db.SaveChanges(); Session["user"] = user.FirstName.ToString() + " " + user.LastName.ToString(); //Session["Role"] = user.Role.ToString(); if (user.Role.ToString() == "Giver") { Giver giver = db.Givers.Where(b => b.UID.Equals(user.UserID)).FirstOrDefault(); int id = giver.GiverID; string path = "Edit/" + id; return(RedirectToAction(path, "Givers")); } return(RedirectToAction("MyAccount", "Users")); } return(View(user)); } else { return(RedirectToAction("MyAccount", "Users")); } } catch { return(RedirectToAction("login", "Users")); } }
public ActionResult DeleteConfirmed(int id) { Giver giver = db.Givers.Find(id); db.Givers.Remove(giver); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "SuperheroID,Name,Power,Age")] Giver giver) { if (ModelState.IsValid) { db.Entry(giver).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(giver)); }
public Quest(string title, string description, Objective[] objectives, int xp = 0, bool side = false, Giver giver = null, Texture2D image = null) { this.title = title; this.description = description; this.objectives = objectives; this.xp = xp; this.side = side; this.giver = giver; this.image = image; }
public ActionResult Edit([Bind(Include = "giverID,award,recongizer,recognized,recognizationDate,employeeId")] Giver giver) { if (ModelState.IsValid) { db.Entry(giver).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(giver)); }
public async Task <ActionResult> Register(RegisterViewModel model) { try { if (ModelState.IsValid) { var user = new ApplicationUser { UserName = model.Email, Email = model.Email }; var result = await UserManager.CreateAsync(user, model.Password); if (result.Succeeded && model.UserType[0] == "Recipient") { var resultRoleAdd = await UserManager.AddToRoleAsync(user.Id, "Recipient"); var db = new ApplicationDbContext(); var recipientAccount = new Recipient { FirstName = model.FirstName, LastName = model.LastName, ApplicationUserId = user.Id }; db.Recipients.Add(recipientAccount); db.SaveChanges(); await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false); // For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771 // Send an email with this link // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id); // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme); // await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>"); return(RedirectToAction("Index", "Home")); } else if (result.Succeeded && model.UserType.Equals("Giver")) { var resultRoleAdd = await UserManager.AddToRoleAsync(user.Id, "Giver"); var db = new ApplicationDbContext(); var giverAccount = new Giver { FirstName = model.FirstName, LastName = model.LastName, ApplicationUserId = user.Id }; db.Givers.Add(giverAccount); db.SaveChanges(); await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false); return(RedirectToAction("Index", "Home")); } AddErrors(result); } } catch (Exception ex) { throw ex; } // If we got this far, something failed, redisplay form return(View(model)); }
public async Task <ActionResult> Register(RegisterViewModel model) { if (ModelState.IsValid) { var user = new ApplicationUser { UserName = model.Email, Email = model.Email, FirstName = model.FirstName, MiddleName = model.MiddleName, LastName = model.LastName }; user.Addresses.Add(new Address { AddressLine1 = model.AddressLine1, AddressLine2 = model.AddressLine2, City = model.City, State = model.State, ZipCode = model.ZipCode }); var result = await UserManager.CreateAsync(user, model.Password); if (result.Succeeded) { // Add Create Giver with that userid Giver giver = new Giver { FirstName = user.FirstName, LastName = user.LastName, Middle = user.MiddleName, AppUserId = user.Id, AddressId = user.Addresses.Select(x => x.ID).FirstOrDefault() }; // Insert new user in giver table _context.Givers.Add(giver); _context.SaveChanges(); // temp code - to create admin user //var roleStore = new RoleStore<IdentityRole>(new ApplicationDbContext()); //var roleManager = new RoleManager<IdentityRole>(roleStore); //await roleManager.CreateAsync(new IdentityRole("CanManageFinance")); //await UserManager.AddToRoleAsync(user.Id, "CanManageFinance"); //await SignInManager.SignInAsync(user, isPersistent:false, rememberBrowser:false); // For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771 // Send an email with this link // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id); // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme); // await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>"); return(RedirectToAction("Index", "Home")); } AddErrors(result); } // If we got this far, something failed, redisplay form return(View(model)); }
// Note that via selective communication it is possible for a job to offer // to both give and take on the same channel simultaneously. So, both // Givers and Takers queues must be maintained even though in many cases // only one of them is non empty. /// Internal implementation detail. internal override void DoJob(ref Worker wr, Cont <T> xK) { TryNextGiver: this.Lock.Enter(); var tail = this.Givers; if (null != tail) { goto TryGiver; } WaitQueue.AddTaker(ref this.Takers, xK); this.Lock.Exit(); return; TryGiver: var cursor = tail.Next; if (tail == cursor) { this.Givers = null; } else { tail.Next = cursor.Next; } this.Lock.Exit(); var pkOther = cursor.Pick; if (null == pkOther) { goto GotGiver; } TryPickOther: var stOther = Pick.TryPick(pkOther); if (stOther > 0) { goto TryNextGiver; } if (stOther < 0) { goto TryPickOther; } Pick.SetNacks(ref wr, cursor.Me, pkOther); GotGiver: var uK = cursor.Cont; uK.Next = null; Worker.Push(ref wr, uK); xK.DoCont(ref wr, cursor.Value); return; }
public ActionResult Edit([Bind(Include = "GiverID,Journal,Navn,Att,Adresse,Postnr,By,AflevDato,Registrator,Note,JournalID")] Giver giver) { if (ModelState.IsValid) { db.Entry(giver).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.JournalID = new SelectList(db.Journaler, "JournalID", "JournalNb", giver.JournalID); return(View(giver)); }
public static bool InsertRecord(Giver giver) { using (UPSSpaceXEntities dbContext = new UPSSpaceXEntities()) { dbContext.Givers.Add(giver); //specifically access the dbContext.SaveChanges(); return(true); } return(false); }
public ActionResult Show(int id) { Giver giver = db.Givers.Find(id); if (giver == null) { return(HttpNotFound()); } TempData["Givers"] = giver; return(RedirectToAction("Index", "Givers")); }
public ActionResult Edit([Bind(Include = "GiverID,Phone,Rating,Address,Latitude,Longtitude")] Giver giver) { if (ModelState.IsValid) { var oldgiver = db.Givers.Find(giver.GiverID); giver.UID = oldgiver.UID; //db.Entry(giver).State = EntityState.Modified; db.Entry(oldgiver).CurrentValues.SetValues(giver); db.SaveChanges(); Session["Address"] = giver.Address.ToString(); return(RedirectToAction("MyAccount", "Users")); } return(View(giver)); }
public ActionResult Create([Bind(Include = "GiverID,Phone,Rating,Address,Latitude,Longtitude")] Giver giver) { if (ModelState.IsValid) { giver.UID = int.Parse(Session["ID"].ToString()); db.Givers.Add(giver); db.SaveChanges(); Session["Address"] = giver.Address.ToString(); Session["GID"] = giver.GiverID.ToString(); return(RedirectToAction("MyAccount", "Users")); } return(View(giver)); }
public ActionResult Create([Bind(Include = "giverID,award,recongizer,recognized,recognizationDate,employeeId")] Giver giver) { if (ModelState.IsValid) { Guid giverId; Guid.TryParse(User.Identity.GetUserId(), out giverId); giver.recongizer = giverId; db.Givers.Add(giver); db.SaveChanges(); return(RedirectToAction("Index")); } //create select list return(View(giver)); }
public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Giver giver = db.Givers.Find(id); if (giver == null) { return(HttpNotFound()); } return(View(giver)); }
// GET: Givers/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Giver giver = db.Giver.Find(id); if (giver == null) { return(HttpNotFound()); } ViewBag.JournalID = new SelectList(db.Journaler, "JournalID", "JournalNb", giver.JournalID); return(View(giver)); }
public ActionResult DeleteConfirmed(int id) { Giver giver = db.Givers.Find(id); User user = db.Users.Find(giver.UID); if (giver.Comments != null) { db.Comments.RemoveRange(giver.Comments); } if (user.UserID == int.Parse(Session["ID"].ToString())) { Session.Clear(); } db.Givers.Remove(giver); db.Users.Remove(user); db.SaveChanges(); return(RedirectToAction("Index")); }
public static bool UpdateDonorFlag(Giver giver) { using (UPSSpaceXEntities dbContext = new UPSSpaceXEntities()) { var query = from db in dbContext.Givers where (db.desk == giver.desk && db.date == giver.date) select db; // Execute the query, and change the column values // you want to change. foreach (Giver db in query) { db.isAvailable = false; // Insert any additional changes to column values. } dbContext.SaveChanges(); return(true); } return(false); }
public static bool UpdateKP(Giver giver) { using (UPSSpaceXEntities dbContext = new UPSSpaceXEntities()) { var query = from db in dbContext.Givers where (db.email == giver.email) select db; // Execute the query, and change the column values // you want to change. foreach (Giver db in query) { db.karmaPoints = db.karmaPoints + 100; // Insert any additional changes to column values. } dbContext.SaveChanges(); return(true); } return(false); }
public void UpdateGiver(Giver giver) { _context.Entry(giver).State = EntityState.Modified; }
public void InsertGiver(Giver giver) { _context.Givers.Add(giver); }
public ActionResult Index([Bind(Include = "FirstName,LastName")] User user, [Bind(Include = "Address,Latitude,Longtitude")] Giver giver) //public ActionResult Index(String FirstName, String LastName) { Func <Giver, Giver, Boolean> CheckDistance = (Giver userloc, Giver g) => { return(Distance(userloc.Latitude, userloc.Longtitude, g.Latitude, lon2: g.Longtitude) < 20); }; try { if (Session["Role"].ToString() != null) { if (user.FirstName == null && user.LastName == null && giver.Latitude == 0 && giver.Longtitude == 0) { var GiversAndUsers = (from g in db.Givers join u in db.Users on g.UID equals u.UserID select new FullGiver { giver = g, user = u }); return(View(GiversAndUsers)); } /*FullGiver fullGiver = new FullGiver(); * fullGiver.user.FirstName = FirstName; * fullGiver.user.LastName = LastName;*/ if (!string.IsNullOrEmpty(user.FirstName) && !string.IsNullOrEmpty(user.LastName)) { var fullGivers = (from g in db.Givers.AsEnumerable() join u in db.Users.AsEnumerable() on g.UID equals u.UserID where (u.FirstName == user.FirstName) && (u.LastName == user.LastName) && (CheckDistance(giver, g)) select new FullGiver { giver = g, user = u }); TempData["FullGivers"] = fullGivers; return(View(fullGivers)); } else if (!string.IsNullOrEmpty(user.FirstName)) { var fullGivers = (from g in db.Givers.AsEnumerable() join u in db.Users.AsEnumerable() on g.UID equals u.UserID where u.FirstName == user.FirstName && (CheckDistance(giver, g)) select new FullGiver { giver = g, user = u }); TempData["FullGivers"] = fullGivers; return(View(fullGivers)); } else if (!string.IsNullOrEmpty(user.LastName)) { var fullGivers = (from g in db.Givers.AsEnumerable() join u in db.Users.AsEnumerable() on g.UID equals u.UserID where u.LastName == user.LastName && (CheckDistance(giver, g)) select new FullGiver { giver = g, user = u }); TempData["FullGivers"] = fullGivers; return(View(fullGivers)); } else { var fullGivers = (from g in db.Givers.AsEnumerable() join u in db.Users.AsEnumerable() on g.UID equals u.UserID where (CheckDistance(giver, g)) select new FullGiver { giver = g, user = u }); TempData["FullGivers"] = fullGivers; return(View(fullGivers)); } } else { return(View()); } } catch { return(RedirectToAction("login", "Users")); } }
public void DeleteGiver(int giverID) { Giver toDelete = _context.Givers.Find(giverID); _context.Givers.Remove(toDelete); }
/// Internal implementation detail. internal override void TryAlt(ref Worker wr, int i, Pick pkSelf, Cont <T> xK) { this.Lock.Enter(); var tail = this.Givers; if (null == tail) { goto TryTaker; } Giver <T> cache = null; var cursor = tail.Next; TryGiver: var giver = cursor; cursor = cursor.Next; var pkOther = giver.Pick; if (null == pkOther) { goto TryPickSelf; } if (pkOther == pkSelf) { goto OtherIsSelf; } TryPickOther: var stOther = Pick.TryClaim(pkOther); if (stOther > 0) { goto TryNextGiver; } if (stOther < 0) { goto TryPickOther; } TryPickSelf: var stSelf = Pick.TryPick(pkSelf); if (stSelf > 0) { goto SelfAlreadyPicked; } if (stSelf < 0) { goto BackOff; } //GotGiver: WaitQueue.ReplaceRange(ref this.Givers, giver, cache); this.Lock.Exit(); if (null != pkOther) { Pick.PickClaimed(pkOther); Pick.SetNacks(ref wr, giver.Me, pkOther); } Pick.SetNacks(ref wr, i, pkSelf); var uK = giver.Cont; uK.Next = null; Worker.Push(ref wr, uK); xK.DoCont(ref wr, giver.Value); return; BackOff: if (null == pkOther) { goto TryPickSelf; } Pick.Unclaim(pkOther); goto TryPickOther; OtherIsSelf: WaitQueue.Enqueue(ref cache, giver); if (giver != tail) { goto TryGiver; } this.Givers = cache; goto TryTaker; TryNextGiver: if (giver != tail) { goto TryGiver; } this.Givers = cache; TryTaker: WaitQueue.AddTaker(ref this.Takers, i, pkSelf, xK); this.Lock.Exit(); xK.TryNext(ref wr, i + 1, pkSelf); return; SelfAlreadyPicked: if (null != pkOther) { Pick.Unclaim(pkOther); } WaitQueue.ReplaceRangeInclusive(this.Givers, giver, cache); this.Lock.Exit(); return; }