public async Task <IActionResult> OnGet(long id, int primary) { PageStack.PushPage(HttpContext.Session, $"/Admin/ShowPerson/{id}", ""); var prim = await this.treeService.GetIndividualById(id).ConfigureAwait(false); if (prim == null) { return(RedirectToPage("Back")); } Primary = new IndividualVm(prim); foreach (var spouseFam in await this.treeService.GetSpouseFamiliesByIndividualId(id, false).ConfigureAwait(false)) { Marriages.Add(new FamilyVm(spouseFam)); } var childFams = await this.treeService.GetChildFamiliesByIndividualId(id, false).ConfigureAwait(false); if (childFams.Any()) { ParentFamily = new FamilyVm(childFams.First()); SetSiblings(); // skip grandparents SortData(); } return(Page()); }
/// <summary> /// Called when a GET request occurs. /// </summary> /// <param name="id">The identifier of the primary.</param> /// <returns></returns> public async Task <IActionResult> OnGet(long id) { var prim = await this.treeService.GetIndividualById(id).ConfigureAwait(false); if (prim == null) { // couldn't find this person so back (?) to the FamilyNames page. return(RedirectToPage("FamilyNames")); } Primary = new IndividualVm(prim); foreach (var spouseFam in await this.treeService.GetSpouseFamiliesByIndividualId(id, false).ConfigureAwait(false)) { Marriages.Add(new FamilyVm(spouseFam)); } var childFams = await this.treeService.GetChildFamiliesByIndividualId(id, false).ConfigureAwait(false); if (childFams.Any()) { ParentFamily = new FamilyVm(childFams.First()); SetSiblings(); if (ParentFamily.Husband != null) // of id != 0 ? { var fams = await this.treeService.GetChildFamiliesByIndividualId(ParentFamily.Husband.Id, false).ConfigureAwait(false); if (fams.Any()) { PaternalGrandparents = new FamilyVm(fams.First()); } } if (ParentFamily.Wife != null) // of id != 0 ? { var fams = await this.treeService.GetChildFamiliesByIndividualId(ParentFamily.Wife.Id, false).ConfigureAwait(false); if (fams.Any()) { MaternalGrandparents = new FamilyVm(fams.First()); } } SortData(); } return(Page()); }