コード例 #1
0
ファイル: PartyService.cs プロジェクト: ephebe/MySecurity
        public void AddAccountability(Party parent,Party child)
        {
            Guard.Against<ArgumentNullException>(_partyHierarchyRepository == null, "建構式需指定repository");

            PartyHierarchy partyHierarchy =
                new PartyHierarchy()
                {
                    Level = 1,
                    ParentPartyId = parent.Id,
                    ChildPartyId = child.Id,
                    PartyHierarchyType = PartyHierarchyType.Accountable
                };
            _partyHierarchyRepository.SaveOrUpdate(partyHierarchy);

            IList<PartyHierarchy> allParents = _partyHierarchyRepository.
                Query(q => q.ChildPartyId == parent.Id && q.PartyHierarchyType == PartyHierarchyType.Accountable);

            foreach(var up in allParents)
            {
                PartyHierarchy hierarchy =
                   new PartyHierarchy()
                   {
                       Level = up.Level + 1,
                       ParentPartyId = up.ParentPartyId,
                       ChildPartyId = child.Id,
                       PartyHierarchyType = up.PartyHierarchyType
                   };
                _partyHierarchyRepository.SaveOrUpdate(hierarchy);
            }
        }
コード例 #2
0
ファイル: PartyService.cs プロジェクト: ephebe/MySecurity
        public void AddEmployeeToPost(Post role, Employee employee)
        {
            Guard.Against<ArgumentNullException>(_partyHierarchyRepository == null, "建構式需指定repository");

            PartyHierarchy partyHierarchy =
               new PartyHierarchy()
               {
                   Level = 1,
                   ParentPartyId = role.Id,
                   ChildPartyId = employee.Id,
                   PartyHierarchyType = PartyHierarchyType.Member
               };
            _partyHierarchyRepository.SaveOrUpdate(partyHierarchy);
        }