public bool Equals(RelationLink other) { if (this.relationType == other.relationType && this.scenarioName == other.scenarioName) { return(true); } return(false); }
public PartialViewResult CreateToddler(CreateToddlerOverview model) { if (ModelState.IsValid) { Toddler toddler = new Toddler(); toddler.ToddlerSession = GetNewChildWizardSession(); toddler.Person = new Person(); toddler.Person.FirstName = model.toddler.Person.FirstName; toddler.Person.LastName = model.toddler.Person.LastName; toddler.Person.Gender = model.toddler.Person.Gender; toddler.Person.BirthDate = model.toddler.Person.BirthDate; toddler.Person.RegistrationDate = DateTime.Now; toddler.Person.Active = false; if (model.toddler.Person.Gender == "male") { toddler.Person.Photo = "baby-boy.png"; } else if (model.toddler.Person.Gender == "female") { toddler.Person.Photo = "baby-girl.png"; } else { toddler.Person.Photo = "stork.png"; } //newToddler = toddler; // TRYOUT db.Toddlers.Add(toddler); db.SaveChanges(); RelationLink relationLink = new RelationLink(); relationLink.RelationToChild = "isChild"; relationLink.Toddler = db.Toddlers.Find(toddler.ToddlerId); relationLink.Person = db.Persons.Find(toddler.Person.PersonId); //newRelationLinks.Add(relationLink); // TRYOUT db.RelationLinks.Add(relationLink); db.SaveChanges(); //db.NewChildWizardSessions.Add(ncws); //db.SaveChanges(); return(PartialView("_ListToddler", toddler)); } else { Toddler current = GetCurrentToddler(); return(PartialView("_ListToddler", current)); } }
public bool IsCompatible(RelationLink other) { if (this.relationType != "ALL" && other.relationType != "ALL" && this.relationType != other.relationType) { return(false); } if (this.scenarioName != "ALL" && other.scenarioName != "ALL" && this.scenarioName != other.scenarioName) { return(false); } return(true); }
public PartialViewResult CreateParent(CreateParentsOverview model) { if (ModelState.IsValid) { Toddler toddler = GetCurrentToddler(); Parent parent = new Parent(); parent.Person = new Person(); parent.Person.FirstName = model.parent.Person.FirstName; parent.Person.LastName = model.parent.Person.LastName; parent.Person.Gender = model.parent.Person.Gender; parent.Person.BirthDate = model.parent.Person.BirthDate; parent.Person.RegistrationDate = DateTime.Now; parent.Person.Active = false; parent.Person.Address = new Address(); parent.Person.Address.City = model.parent.Person.Address.City; parent.Person.Address.PostalCode = model.parent.Person.Address.PostalCode; parent.Person.Address.Street = model.parent.Person.Address.Street; parent.Person.Address.Number = model.parent.Person.Address.Number; parent.Person.Address.Bus = model.parent.Person.Address.Bus; parent.Person.ContactDetail = new ContactDetail(); parent.Person.ContactDetail.HomePhone = model.parent.Person.ContactDetail.HomePhone; parent.Person.ContactDetail.CellPhone = model.parent.Person.ContactDetail.CellPhone; parent.Person.ContactDetail.WorkPhone = model.parent.Person.ContactDetail.WorkPhone; parent.Person.ContactDetail.Email = model.parent.Person.ContactDetail.Email; db.Parents.Add(parent); db.SaveChanges(); RelationLink relationLink = new RelationLink(); relationLink.Person = db.Persons.Find(parent.PersonId); relationLink.Toddler = toddler; relationLink.RelationToChild = "isParent"; db.RelationLinks.Add(relationLink); db.SaveChanges(); } return(PartialView("_ListParents", GetParentsOfCurrentToddler())); }
public PartialViewResult CreatePickup(CreateAgreedDaysAndPickup model) { string session = GetNewChildWizardSession(); if (ModelState.IsValid) { Toddler toddler = GetCurrentToddler(); Pickup pickup = new Pickup(); pickup.Relation = model.pickup.Relation; pickup.Person = new Person(); pickup.Person.FirstName = model.pickup.Person.FirstName; pickup.Person.LastName = model.pickup.Person.LastName; pickup.Person.BirthDate = DateTime.Now; pickup.Person.RegistrationDate = DateTime.Now; pickup.Person.Active = false; pickup.Person.Address = new Address(); pickup.Person.Address.City = model.pickup.Person.Address.City; pickup.Person.Address.PostalCode = model.pickup.Person.Address.PostalCode; pickup.Person.ContactDetail = new ContactDetail(); pickup.Person.ContactDetail.CellPhone = model.pickup.Person.ContactDetail.CellPhone; db.Pickups.Add(pickup); db.SaveChanges(); RelationLink relationLink = new RelationLink(); relationLink.RelationToChild = "isPickup"; relationLink.Person = db.Persons.Find(pickup.PersonId); relationLink.Toddler = toddler; db.RelationLinks.Add(relationLink); db.SaveChanges(); } return(PartialView("_ListPickups", GetPickupsOfCurrentToddler())); }
public Dictionary <string, HashSet <string> > GetChildrenIds(string vertexId, string relationType, string scenarioName) { if (string.IsNullOrWhiteSpace(vertexId)) { return(null); } RelationLink targetLink = new RelationLink(relationType, scenarioName); Dictionary <string, HashSet <string> > childrenIds = new Dictionary <string, HashSet <string> >(); if (outRelationDict.ContainsKey(vertexId)) { foreach (RelationLink link in outRelationDict[vertexId].Keys) { if (targetLink.IsCompatible(link)) { string linkRelationType = link.relationType; if (!childrenIds.ContainsKey(linkRelationType)) { HashSet <string> cIds = new HashSet <string>(); childrenIds.Add(linkRelationType, cIds); } List <string> conncectedIds = outRelationDict[vertexId][link]; foreach (string cid in conncectedIds) { childrenIds[linkRelationType].Add(cid); } } } } return(childrenIds); }
/// <summary> /// Deserialized an XML response into an instance of this object. /// </summary> /// <param name="reader">An XmlReader object.</param> public void ReadXml(XmlReader reader) { reader.MoveToFirstAttribute(); do { switch (reader.Name) { case "id": this.id = reader.ReadContentAsString(); break; case "type": this.type = reader.ReadContentAsString(); break; case "userDefined": this.userDefined = reader.ReadContentAsBoolean(); break; case "visible": this.visible = reader.ReadContentAsBoolean(); break; case "editable": this.editable = reader.ReadContentAsBoolean(); break; } } while (reader.MoveToNextAttribute()); List <string> values = new List <string>(); List <RelationLink> links = new List <RelationLink>(); while (reader.Read()) { if (reader.NodeType == XmlNodeType.Element) { switch (reader.Name) { case "values": reader.ReadToDescendant("value"); values.Add(reader.ReadString()); break; case "value": values.Add(reader.ReadString()); break; case "name": this.name = reader.ReadString(); break; case "link": case "links": if (reader.Name == "links") { reader.ReadToDescendant("link"); } RelationLink link = new RelationLink(); reader.MoveToFirstAttribute(); link.Rel = "self"; while (reader.MoveToNextAttribute()) { if (reader.Name == "href") { link.URL = reader.ReadContentAsString(); } else if (reader.Name == "rel") { link.Rel = reader.ReadContentAsString(); } } links.Add(link); break; } } else if (reader.NodeType == XmlNodeType.EndElement && reader.Name == "metadataField") { reader.Read(); break; } } this.values = values.ToArray(); this.links = new RelationLink[] { }; }