示例#1
0
        private void ProcessUnionDescendants(List <Repo.Core.Model.Union> unions, Repo.Core.Model.Union union, List <Repo.Core.Model.Person> peopleLookup, List <Person> peopleList, List <Guid> processedUnions)
        {
            if (processedUnions.Any(u => u == union.ID))
            {
                return;
            }

            var partner1 = peopleList.FirstOrDefault(p => p.Id == union.PartnerID);
            var partner2 = peopleList.FirstOrDefault(p => p.Id == union.Partner2ID);
            var children = peopleList.Where(c => c.ParentRelationship == union.ID);
            //var children = peopleLookup.Where(f => f?.ParentRelationship == union.ID);
            //make the union
            var newUnion = new Models.Union
            {
                Partner1          = partner1,
                Partner2          = partner2,
                DateOfUnion       = union.MarriageDate,
                DateOfDissolution = union.DivorceDate,
                Descendents       = children.ToList(),
                Divorced          = union.IsEnded,
                Id = union.ID
            };

            processedUnions.Add(union.ID);


            partner1?.Unions.Add(newUnion);
            partner2?.Unions.Add(newUnion);
        }
        public async Task <IActionResult> Union(Models.Union union)
        {
            if (ModelState.IsValid)
            {
                var dbUnion = union.Map();
                await _unionWriteRepository.Save(dbUnion, GetCancellationToken());

                _clanAndPeopleService.ClearPeople();
            }
            return(RedirectToAction("Relationship", new { partner1 = union.Partner1.Id, partner2 = union.Partner2.Id }));
        }