Esempio n. 1
0
        public UserGroupMembership(UserGroup userGroup, User user, UserGroupMembershipType membershipType, EntityCreatedDto entityCreatedDto)
        {
            Require.NotNull(userGroup, "userGroup");
            Require.NotNull(user, "user");
            Require.NotNull(entityCreatedDto, "entityCreatedDto");

            _account        = new Account(this);
            _userGroup      = userGroup;
            _user           = user;
            _membershipType = membershipType;
            _createdAt      = entityCreatedDto.CreatedAt;
            _createdBy      = entityCreatedDto.CreatedBy;
        }
Esempio n. 2
0
        public void UpdateMembershipTypes(IDictionary <UserGroupMembership, UserGroupMembershipType> memberships, User changedBy)
        {
            Require.NotNull(memberships, "memberships");
            Require.NotNull(changedBy, "changedBy");

            foreach (UserGroupMembership userGroupMembership in memberships.Keys)
            {
                UserGroupMembershipType newMembershipType = memberships[userGroupMembership];
                if (userGroupMembership.MembershipType != newMembershipType)
                {
                    userGroupMembership.Update(newMembershipType, new EntityChangedDto(changedBy, DateTime.Now));
                }
            }
        }
Esempio n. 3
0
        public virtual void Update(UserGroupMembershipType membershipType, EntityChangedDto entityChangedDto)
        {
            _membershipType = membershipType;

            Update(entityChangedDto);
        }
        public UserGroupMembership Create(UserGroup userGroup = null, User user = null, UserGroupMembershipType membershipType = UserGroupMembershipType.Member, User createdBy = null, DateTime?createdAt = null, bool persist = true)
        {
            if (createdBy == null)
            {
                createdBy = UserCreator.Create(persist: persist);
            }
            if (!createdAt.HasValue)
            {
                createdAt = DateTime.Now;
            }

            if (userGroup == null)
            {
                userGroup = UserGroupCreator.Create(createdBy: createdBy, persist: persist);
            }
            if (user == null)
            {
                user = UserCreator.Create(creationDto: new EntityCreatedDto(createdBy, createdAt.Value), persist: persist);
            }

            UserGroupMembership userGroupMembership = new UserGroupMembership(userGroup, user, membershipType, new EntityCreatedDto(createdBy, createdAt.Value));

            if (persist)
            {
                UserGroupMembershipDao.Save(userGroupMembership);
                UserGroupMembershipDao.Flush();
            }


            return(userGroupMembership);
        }