public async Task <IActionResult> Edit(int id, [Bind("SiblingId,FirstName,LastName,Age,Gender,IsAlive,PersonId")] Sibling sibling) { if (id != sibling.SiblingId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(sibling); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SiblingExists(sibling.SiblingId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(sibling)); }
public ActionResult SubmitAddSiblingInfo(Sibling sibling) { Guid UserID = Guid.Parse(HttpContext.User.Identity.GetUserId()); using (UserContext db = new UserContext()) { //get user var data = db.Users .Include(u => u.Siblings) .Where(u => u.UserID == UserID) .FirstOrDefault <UserModel>(); //check null sibling list if (data.Siblings == null) { data.Siblings = new List <Sibling>(); } //set ID and add sibling sibling.UserID = UserID; data.Siblings.Add(sibling); //save db.SaveChanges(); return(PartialView("_GetSiblingInfo", data.Siblings)); } }
public void ToStructVariables(TextWriter writer, bool DX, List <string> labels, string[] textures = null) { for (int i = 1; i < Children.Count; i++) { Children[i - 1].Sibling = Children[i]; } for (int i = Children.Count - 1; i >= 0; i--) { if (!labels.Contains(Children[i].Name)) { labels.Add(Children[i].Name); Children[i].ToStructVariables(writer, DX, labels, textures); writer.WriteLine(); } } if (Parent == null && Sibling != null && !labels.Contains(Sibling.Name)) { labels.Add(Sibling.Name); Sibling.ToStructVariables(writer, DX, labels, textures); writer.WriteLine(); } if (Attach != null && !labels.Contains(Attach.Name)) { labels.Add(Attach.Name); Attach.ToStructVariables(writer, DX, labels, textures); writer.WriteLine(); } writer.Write("NJS_OBJECT "); writer.Write(Name); writer.Write(" = "); writer.Write(ToStruct()); writer.WriteLine(";"); }
public Parent() { _walkChildren = new List<Child>(); _noWalkChildren = new List<Child>(); _parentChildren = new List<Parent>(); _sibling = new Sibling(); }
public void StripPolyCache() { if (Attach is ChunkAttach attach && attach.Poly != null) { for (int i = 0; i < attach.Poly.Count; i++) { switch (attach.Poly[i].Type) { case ChunkType.Bits_CachePolygonList: PolyCache[((PolyChunkBitsCachePolygonList)attach.Poly[i]).List] = attach.Poly.Skip(i + 1).ToList(); attach.Poly = attach.Poly.Take(i).ToList(); break; case ChunkType.Bits_DrawPolygonList: int list = ((PolyChunkBitsDrawPolygonList)attach.Poly[i]).List; attach.Poly.RemoveAt(i); attach.Poly.InsertRange(i--, PolyCache[list]); break; } } if (attach.Poly.Count == 0) { attach.Poly = null; attach.PolyName = null; } } foreach (NJS_OBJECT child in Children) { child.StripPolyCache(); } if (Parent == null && Sibling != null) { Sibling.StripPolyCache(); } }
/// <summary> /// Adds a node to the Sibling Graph. /// </summary> /// <param name="child">The FrameworkElement to add to the graph</param> /// <param name="dependencies">The dependencies this FrameworkElement has</param> internal void AddNode(IFrameworkElement child, Dependency[] dependencies) { var node = new Sibling(child); // For each dependency of this node, create the node and create inter-dependencies for the siblings foreach (var dependency in dependencies) { // Find the sibling in the currently existing nodes var sibling = _nodes .Where(n => n.Element.Equals(dependency.Element)) .FirstOrDefault(); // If the sibling is found, set the bi-directional relationship between the siblings if (sibling != null) { node.Dependencies.Add(new SiblingDependency(sibling, dependency.Type)); sibling.Dependencies.Add(new SiblingDependency(node, GetOppositeDependency(dependency.Type), true)); } } // If the node has no dependencies, it is considered to be a graph entry point if (dependencies.Length == 0) { _entryPoints.Add(node); } _nodes.Add(node); }
public NJS_OBJECT Clone() { NJS_OBJECT result = (NJS_OBJECT)MemberwiseClone(); if (Attach != null) { result.Attach = Attach.Clone(); } result.Position = Position.Clone(); result.Rotation = Rotation.Clone(); result.Scale = Scale.Clone(); result.children = new List <NJS_OBJECT>(children.Count); result.Children = new ReadOnlyCollection <NJS_OBJECT>(result.children); if (children.Count > 0) { NJS_OBJECT child = children[0].Clone(); while (child != null) { result.children.Add(child); child = child.Sibling; } } if (Sibling != null) { result.Sibling = Sibling.Clone(); } return(result); }
internal List <KeyValuePair <string, object> > GetParameters(int num) { var parameters = new List <KeyValuePair <string, object> >(); if (RightValue != null) { ParameterName = $"Param{num}"; parameters.Add(new KeyValuePair <string, object>(ParameterName, RightValue)); } foreach (var p in AdditionalParameterValues) { var paramName = $"Param{num + parameters.Count}"; var kvp = new KeyValuePair <string, object>(paramName, p); parameters.Add(kvp); AdditionalParameters.Add(kvp); } if (ConditionGroup != null) { parameters.AddRange(ConditionGroup.GetParameters(num + parameters.Count)); } if (Sibling != null) { parameters.AddRange(Sibling.GetParameters(num + parameters.Count)); } return(parameters); }
public void ToNJA(TextWriter writer, bool DX, List <string> labels, string[] textures = null) { for (int i = 1; i < Children.Count; i++) { Children[i - 1].Sibling = Children[i]; } for (int i = Children.Count - 1; i >= 0; i--) { if (!labels.Contains(Children[i].Name)) { labels.Add(Children[i].Name); Children[i].ToNJA(writer, DX, labels, textures); writer.WriteLine(); } } if (Parent == null && Sibling != null && !labels.Contains(Sibling.Name)) { labels.Add(Sibling.Name); Sibling.ToNJA(writer, DX, labels, textures); writer.WriteLine(); } writer.WriteLine("OBJECT_START"); if (Attach is BasicAttach) { BasicAttach basicattach = Attach as BasicAttach; basicattach.ToNJA(writer, DX, labels, textures); } writer.Write("OBJECT "); writer.Write(Name); writer.WriteLine("[]"); writer.WriteLine("START"); writer.WriteLine("EvalFlags ( " + ((StructEnums.NJD_EVAL)GetFlags()).ToString().Replace(", ", " | ") + " ),"); writer.WriteLine("Model " + (Attach != null ? "&" + Attach.Name : "NULL") + ","); writer.Write("OPosition ( "); foreach (float value in Position.ToArray()) { writer.Write(value.ToC()); writer.Write(", "); } writer.WriteLine("),"); writer.Write("OAngle ( "); foreach (float value in Rotation.ToArray()) { writer.Write(value.ToC()); writer.Write(", "); } writer.WriteLine("),"); writer.Write("OScale ( "); foreach (float value in Scale.ToArray()) { writer.Write(value.ToC()); writer.Write(", "); } writer.WriteLine("),"); writer.WriteLine("Child " + (Children.Count > 0 ? Children[0].Name : "NULL") + ","); writer.WriteLine("Sibling " + (Sibling != null ? Sibling.Name : "NULL")); writer.WriteLine("END"); writer.WriteLine("OBJECT_END"); }
public ActionResult DeleteConfirmed(string id) { Sibling sibling = db.Siblings.Find(id); db.Siblings.Remove(sibling); db.SaveChanges(); return(RedirectToAction("Index")); }
private static string GetSiblingPart(Sibling s) { if (s.Preceding == true) { return(string.Format("preceding-sibling::{0}", s.Name)); } return(string.Format("following-sibling::{0}", s.Name)); }
public async Task <ActionResult> Register(RegisterViewModel model) { if (ModelState.IsValid) { var user = new ApplicationUser { UserName = model.Email, Email = model.Email }; var result = await UserManager.CreateAsync(user, model.Password); if (result.Succeeded) { if (model.IsDriver) { UserManager.AddToRole(user.Id, "Driver"); var driver = new Driver { Email = model.Email, Name = model.FirstName, Id = user.Id }; db.Drivers.Add(driver); } else { UserManager.AddToRole(user.Id, "SIbling"); var sibling = new Sibling { Email = model.Email, FirstName = model.FirstName, LastName = model.LastName, Address = model.Address, GroupId = model.GroupId.Value, PhoneNumber = model.PhoneNumber, Id = user.Id }; db.Siblings.Add(sibling); } db.SaveChanges(); await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false); // For more information on how to enable account confirmation and password reset please visit https://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 ViewBag.AllSiblingGroups = new SelectList(db.SiblingGroups.OrderBy(G => G.Name), "Id", "Name"); return(View(model)); }
public ActionResult Edit([Bind(Include = "SibilingID,SiblingCount")] Sibling sibling) { if (ModelState.IsValid) { db.Entry(sibling).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(sibling)); }
private void SibGrid_SelectionChanged(object sender, SelectionChangedEventArgs e) { Sibling SelectedSib = ((Sibling)SibGrid.SelectedItem); if (SelectedSib != null) { ChildName.Text = SelectedSib.Name.ToString(); Phone.Text = SelectedSib.Phone.ToString(); } }
public void ToNJA(TextWriter writer, bool DX, List <string> labels, string[] textures = null) { for (int i = 1; i < Children.Count; i++) { Children[i - 1].Sibling = Children[i]; } for (int i = Children.Count - 1; i >= 0; i--) { if (!labels.Contains(Children[i].Name)) { labels.Add(Children[i].Name); Children[i].ToNJA(writer, DX, labels, textures); writer.WriteLine(); } } if (Parent == null && Sibling != null && !labels.Contains(Sibling.Name)) { labels.Add(Sibling.Name); Sibling.ToNJA(writer, DX, labels, textures); writer.WriteLine(); } writer.WriteLine("OBJECT_START" + Environment.NewLine); if (Attach is BasicAttach) { BasicAttach basicattach = Attach as BasicAttach; basicattach.ToNJA(writer, DX, labels, textures); } else if (Attach is ChunkAttach) { //ChunkAttach ChunkAttach = Attach as ChunkAttach; //ChunkAttach.ToNJA(writer, labels, textures); } writer.Write("OBJECT "); writer.Write(Name); writer.WriteLine("[]"); writer.WriteLine("START"); writer.WriteLine("EvalFlags ( " + ((StructEnums.NJD_EVAL)GetFlags()).ToString().Replace(", ", " | ") + " ),"); writer.WriteLine("Model " + (Attach != null ? Attach.Name : "NULL") + ","); writer.WriteLine("OPosition ( " + Position.X.ToC() + ", " + Position.Y.ToC() + ", " + Position.Z.ToC() + " ),"); writer.WriteLine("OAngle ( " + ((float)Rotation.X / 182.044f).ToC() + ", " + ((float)Rotation.Y / 182.044f).ToC() + ", " + ((float)Rotation.Z / 182.044f).ToC() + " ),"); writer.WriteLine("OScale ( " + Scale.X.ToC() + ", " + Scale.Y.ToC() + ", " + Scale.Z.ToC() + " ),"); writer.WriteLine("Child " + (Children.Count > 0 ? Children[0].Name : "NULL") + ","); writer.WriteLine("Sibling " + (Sibling != null ? Sibling.Name : "NULL")); writer.WriteLine("END" + Environment.NewLine); writer.WriteLine("OBJECT_END"); if (Parent == null) { writer.WriteLine(Environment.NewLine + "DEFAULT_START"); writer.WriteLine(Environment.NewLine + "#ifndef DEFAULT_OBJECT_NAME"); writer.WriteLine("#define DEFAULT_OBJECT_NAME " + Name); writer.WriteLine("#endif"); writer.WriteLine(Environment.NewLine + "DEFAULT_END"); } }
public ActionResult Edit([Bind(Include = "Id,GroupId,FirstName,LastName,Address,PhoneNumber,Email")] Sibling sibling) { if (ModelState.IsValid) { db.Entry(sibling).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.GroupId = new SelectList(db.SiblingGroups, "Id", "Name", sibling.GroupId); return(View(sibling)); }
public ActionResult Create([Bind(Include = "SibilingID,SiblingCount")] Sibling sibling) { if (ModelState.IsValid) { db.Siblings.Add(sibling); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(sibling)); }
private void DeleteBtn_Click(object sender, RoutedEventArgs e) { Sibling SelectedSib = ((Sibling)SibGrid.SelectedItem); if (SelectedSib != null) { _context.Entry(SelectedSib).State = System.Data.Entity.EntityState.Deleted; _context.SaveChanges(); Clear(); } }
public async Task <IActionResult> Create([Bind("SiblingId,FirstName,LastName,Age,Gender,IsAlive,PersonId")] Sibling sibling) { if (ModelState.IsValid) { _context.Add(sibling); await _context.SaveChangesAsync(); //return RedirectToAction(nameof(Index)); return(RedirectToAction("Index", "People")); } return(View(sibling)); }
public void DeleteSibling(string fieldId) { Sibling sibling = new Sibling(); sibling.fieldId = Int32.Parse(fieldId); using (UserContext db = new UserContext()) { db.Siblings.Attach(sibling); db.Siblings.Remove(sibling); db.SaveChanges(); } }
public void AddTo(BinomialHeap <T> otherHeap) { otherHeap.Insert(Value); if (Sibling != null) { Sibling.AddTo(otherHeap); } if (Child != null) { Child.AddTo(otherHeap); } }
// GET: Siblings/Details/5 public ActionResult Details(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Sibling sibling = db.Siblings.Find(id); if (sibling == null) { return(HttpNotFound()); } return(View(sibling)); }
public int CountMorph() { int result = Morph ? 1 : 0; foreach (NJS_OBJECT item in Children) { result += item.CountMorph(); } if (Parent == null && Sibling != null) { result += Sibling.CountMorph(); } return(result); }
public int Size(int i) { ++i; if (Sibling != null) { Sibling.Size(i); } if (Child != null) { Child.Size(i); } return(i); }
public int Count() { var count = 1; if (Child != null) { count += Child.Count(); } if (Sibling != null) { count += Sibling.Count(); } return(count); }
private void EditBtn_Click(object sender, RoutedEventArgs e) { Sibling SelectedSib = ((Sibling)SibGrid.SelectedItem); if (SelectedSib != null) { SelectedSib.Name = ChildName.Text.Trim(); SelectedSib.Phone = Convert.ToInt64(Phone.Text.Trim()); _context.Entry(SelectedSib).State = System.Data.Entity.EntityState.Modified; _context.SaveChanges(); Clear(); refreshBtn_Click(); } }
// GET: Siblings/Edit/5 public ActionResult Edit(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Sibling sibling = db.Siblings.Find(id); if (sibling == null) { return(HttpNotFound()); } ViewBag.GroupId = new SelectList(db.SiblingGroups, "Id", "Name", sibling.GroupId); return(View(sibling)); }
public NJS_OBJECT[] GetObjects() { List <NJS_OBJECT> result = new List <NJS_OBJECT> { this }; foreach (NJS_OBJECT item in Children) { result.AddRange(item.GetObjects()); } if (Parent == null && Sibling != null) { result.AddRange(Sibling.GetObjects()); } return(result.ToArray()); }
void UpdateElementVisiblity() { if (m_CustomLock) { return; } if (Sibling == null) { return; } Rect targetRect = Sibling.QuickRect(); if (Sibling is LMS_GuiBaseVerticalScroller) { m_Hidden = QuickRect().y > targetRect.y; } }
public void ProcessVertexData() { #if modellog Extensions.Log("Processing Object " + Name + Environment.NewLine); #endif if (Attach != null) { Attach.ProcessVertexData(); } foreach (NJS_OBJECT item in Children) { item.ProcessVertexData(); } if (Parent == null && Sibling != null) { Sibling.ProcessVertexData(); } }
public static void LinkWherePossible(BaseController Controller) { Cursor.Current = Cursors.WaitCursor; ApsimFile.Component Base = Controller.Selection; List <ApsimFile.Component> Siblings = new List <ApsimFile.Component>(); Base.Parent.FindRecursively(Base.Type, ref Siblings); foreach (ApsimFile.Component Sibling in Siblings) { if (Sibling.FullPath != Base.FullPath) { Sibling.ConvertToShortcutsUsingBase(Base); } } Controller.ApsimData.PublishComponentChanged(Controller.ApsimData.RootComponent); Cursor.Current = Cursors.Default; }
public GrandChild(Sibling sibling) { }
public Parent(Child child, Sibling sibling, GrandParent grandParent) { }
private void Battle(Sibling sibling, Enemy enemy) { if(sibling.Weapon.Beats(enemy.Weapon)) { sibling.Attack(); enemy.Die(); } else if(enemy.Weapon.Beats(sibling.Weapon)) { if(sibling.Ability) { sibling.UseAbility(); enemy.Die(); } else { sibling.Die(); enemy.Attack(); } } }