Пример #1
0
        public UserGroupPoco MapIt(UserGroupPoco a, UserGroupPermissionsPoco c, User2UserGroupPoco b)
        {
            if (a == null)
            {
                return(Current);
            }

            if (Current != null && Current.GroupId == b.GroupId)
            {
                if (Current.Users.All(u => u.UserId != b.UserId))
                {
                    Current.Users.Add(b);
                }

                if (Current.Permissions.All(p => p.Id != c.Id))
                {
                    Current.Permissions.Add(c);
                }
                return(null);
            }

            var prev = Current;

            Current = a;

            if (Current.GroupId == b.GroupId)
            {
                Current.Users = new List <User2UserGroupPoco>()
                {
                    b
                };
            }

            if (Current.GroupId == c.GroupId)
            {
                Current.Permissions = new List <UserGroupPermissionsPoco>()
                {
                    c
                };
            }

            return(prev);
        }
Пример #2
0
 /// <summary>
 /// Adds the given user record to the database, creating a relationship with a group
 /// </summary>
 /// <param name="user">The user to insert, of type <see cref="User2UserGroupPoco"/></param>
 public void AddUserToGroup(User2UserGroupPoco user)
 {
     _database.Insert(user);
 }
        /// <summary>
        /// Maps Users to the UserGroup property of a UserGroupPermissionsPoco
        /// </summary>
        /// <param name="ugpp"></param>
        /// <param name="ugp"></param>
        /// <param name="u2Ugp"></param>
        /// <returns></returns>
        public UserGroupPermissionsPoco MapIt(UserGroupPermissionsPoco ugpp, UserGroupPoco ugp, User2UserGroupPoco u2Ugp)
        {
            if (ugpp == null)
            {
                return(Current);
            }

            if (Current != null && Current.GroupId == ugpp.GroupId)
            {
                if (Current.UserGroup == null)
                {
                    Current.UserGroup = ugp;
                }

                if (Current.GroupId == u2Ugp.GroupId)
                {
                    Current.UserGroup.Users.Add(u2Ugp);
                }
                return(null);
            }

            var prev = Current;

            Current           = ugpp;
            Current.UserGroup = ugp;

            if (Current.GroupId == u2Ugp.GroupId)
            {
                Current.UserGroup.Users.Add(u2Ugp);
            }

            return(prev);
        }