private void btnSelectParents_Click(object sender, EventArgs e) { var list = new MarriageRepository().FindAll(fetchExtensions: true); var form = new SelectorUI<Marriage>(list); form.ShowDialog(); var selectedItem = form.SelectedItem; if (selectedItem != null) this.ParentsMarriage = selectedItem; UpdateRelationshipsView(); }
public Person FindPartner(Person person) { var marriage = new MarriageRepository().FindByPerson(person); if(marriage != null) { var partnerId = marriage.husband_id; if (partnerId == person.id) partnerId = marriage.wife_id; var partner = DB.Database.GetDatabase().FetchBy<Person>(sql => sql.Where(x => x.id.Equals(partnerId))).FirstOrDefault(); return partner; } else { return null; } }
public Person FindPartner(Person person) { var marriage = new MarriageRepository().FindByPerson(person); if (marriage != null) { var partnerId = marriage.husband_id; if (partnerId == person.id) { partnerId = marriage.wife_id; } var partner = DB.Database.GetDatabase().FetchBy <Person>(sql => sql.Where(x => x.id.Equals(partnerId))).FirstOrDefault(); return(partner); } else { return(null); } }
public string GetAllItemsAsJson() { var persons = new PersonRepository().FindAll(); var marriages = new MarriageRepository().FindAll(); var marriageSons = new MarriageSonRepository().FindAll(); int counter = 0; var personsAsJs = GetPersonsAsJsNodes( persons, ref counter); var marriagesAsJs = GetMarriagesAsJsNodes(marriages, ref counter); var nodesAsJs = new List<string>(); nodesAsJs.AddRange(personsAsJs.Select(x => x.Value.Item2)); nodesAsJs.AddRange(marriagesAsJs.Select(x => x.Value.Item2)); var linksAsJs = GetLinksAsJs(marriageSons, marriages, personsAsJs, marriagesAsJs); var fullJs = String.Format(@"{{""directed"": true, ""graph"": [], ""nodes"": [{0}] , ""links"": [{1}] , ""multigraph"": false}}", String.Join(",\r\n", nodesAsJs), String.Join(",\r\n", linksAsJs)); return fullJs; }