示例#1
0
        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());
        }
示例#2
0
        /// <summary>
        /// Called when a GET request occurs.
        /// </summary>
        public async Task <IActionResult> OnGet()
        {
            PageStack.PushPage(HttpContext.Session, "/Admin/EditFamily", $"id={Id}");
            if (this.Id <= 0)
            {
                // create new family
                // todo: who are the spouses?
                this.MarriageDate = new MutableGeneaDate();
            }
            else
            {
                FamilyDto fam = await this.treeService.GetFamilyById(this.Id).ConfigureAwait(false);

                if (fam is null)
                {
                    // explicit ID not found
                    return(RedirectToPage("Index"));
                }

                this.MarriageDate  = new MutableGeneaDate(fam.MarriageDate);
                this.MarriagePlace = fam.MarriagePlace;
                this.DivorceDate   = new MutableGeneaDate(fam.DivorceDate);
                this.DivorcePlace  = fam.DivorcePlace;

                this.FamilyName = string.Join(" and ", fam.Spouses.Select(sp => $"{sp.Firstnames}"));
            }

            return(Page());
        }
        public IActionResult OnGet()
        {
            PageStack.PushPage(HttpContext.Session, "/Admin/AddFamily", "");

            // TODO
            return(RedirectToPage("Back"));
        }
示例#4
0
        public async Task OnGet(string firstname, string lastname)
        {
            PageStack.PushPage(HttpContext.Session, "/Admin/Search", $"firstname={Uri.EscapeDataString(firstname??"")}&lastname={Uri.EscapeDataString(lastname??"")}");
            this.Firstname = firstname;
            this.Lastname  = lastname;

            if (!string.IsNullOrWhiteSpace(Firstname) || !string.IsNullOrWhiteSpace(Lastname))
            {
                var qry = await this.treeService.SearchByName(Firstname, Lastname).ConfigureAwait(false);

                this.List.AddRange(qry.Select(i => new IndividualVm(i)));
            }
        }
示例#5
0
        public async Task <IActionResult> OnGet(long primary, long cfam, long sfam)
        {
            PageStack.PushPage(HttpContext.Session, "/Admin/EditPerson", $"primary={primary}&cfam={cfam}&sfam={sfam}");
            this.Primary   = primary;
            this.ChildFam  = cfam;
            this.SpouseFam = sfam;

            if (this.Id > 0)
            {
                var indi = await this.treeService.GetIndividualById(this.Id).ConfigureAwait(false);

                if (indi == null)
                {
                    return(RedirectToPage("Index"));
                }
                this.Person = new IndividualVm(indi);
            }
            else
            {
                this.Person = new IndividualVm();
            }

            return(Page());
        }
示例#6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DeletePersonModel"/> class.
 /// </summary>
 /// <param name="treeService">The tree service.</param>
 public DeletePersonModel(TreeService treeService)
 {
     PageStack.PushPage(HttpContext.Session, "/Admin/DeletePerson", $"id={Id}");
     this.treeService = treeService;
 }