Beispiel #1
0
 private Principal ToModel(Persistance.Models.Principal entity)
 {
     if (entity == null)
     {
         return(null);
     }
     return(Principal.From(CPN.FromValue(entity.CanonicalName))
            .WithChildren(entity.ChildRelations.Select(r => CPN.FromValue(r.Child.CanonicalName)).ToArray()));
 }
Beispiel #2
0
        private void AddRelation(Persistance.Models.Principal parent, CPN child)
        {
            var found = this.context.Principals.FirstOrDefault(p => p.CanonicalName == child.Value);

            if (found == null)
            {
                return;
            }
            this.context.Add(new Persistance.Models.PrincipalRelation()
            {
                Parent = parent,
                Child  = found
            });
        }
Beispiel #3
0
        public void Add(Principal principal)
        {
            var toAdd = new Persistance.Models.Principal()
            {
                CanonicalName = principal.Identifier
            };

            this.context.Add(toAdd);

            foreach (var child in principal.Children)
            {
                AddRelation(toAdd, child);
            }

            this.context.SaveChanges();
        }