protected override string ExecuteWorkImplementation()
        {
            var singleUserGroupSubwork = new SingleUserGroupSubwork(m_userRepository, m_codeGenerator);

            var userGroup = m_userRepository.GetSingleUserGroup(m_userId);

            userGroup.Name = singleUserGroupSubwork.GetUniqueName();

            m_userRepository.Update(userGroup);

            return(userGroup.Name);
        }
Пример #2
0
        private SingleUserGroup CreateSingleUserGroupObject(User user, DateTime now)
        {
            var singleUserGroupSubwork = new SingleUserGroupSubwork(m_userRepository, m_codeGenerator);
            var result = new SingleUserGroup
            {
                Name       = singleUserGroupSubwork.GetUniqueName(),
                CreateTime = now,
                LastChange = now,
                User       = user,
                Users      = new List <User> {
                    user
                },
                Permissions = null,
            };

            return(result);
        }
Пример #3
0
        protected override int ExecuteWorkImplementation()
        {
            var client = m_communicationProvider.GetAuthRegistrationApiClient();

            var authUser = new Ridics.Authentication.DataContracts.User.CreateUserContract
            {
                Password = m_data.NewPassword,
                UserName = m_data.UserName,
                User     = new UserContractBase
                {
                    FirstName   = m_data.FirstName,
                    LastName    = m_data.LastName,
                    Email       = m_data.Email,
                    PhoneNumber = null
                }
            };

            var user = client.CreateUserAsync(authUser).GetAwaiter().GetResult();

            var now = DateTime.UtcNow;

            var dbUser = new User
            {
                ExternalId     = user.Id,
                CreateTime     = now,
                ExtUsername    = user.UserName,
                ExtFirstName   = user.FirstName,
                ExtLastName    = user.LastName,
                Groups         = null,
                FavoriteLabels = null,
            };

            var singleUserGroupSubwork = new SingleUserGroupSubwork(m_userRepository, m_codeGenerator);
            var singleUserGroup        = new SingleUserGroup
            {
                Name       = singleUserGroupSubwork.GetUniqueName(),
                CreateTime = now,
                LastChange = now,
                User       = dbUser,
                Users      = new List <User> {
                    dbUser
                },
                Permissions = null,
            };

            dbUser.Groups = new List <UserGroup> {
                singleUserGroup
            };
            // RoleUserGroups are assigned on every login


            var userFavoriteLabelSubwork = new UserFavoriteLabelSubwork(m_userRepository);
            var defaultFavoriteLabel     = userFavoriteLabelSubwork.GetNewDefaultFavoriteLabel(dbUser);

            dbUser.FavoriteLabels = new List <FavoriteLabel> {
                defaultFavoriteLabel
            };


            var userId = (int)m_userRepository.Create(dbUser);

            return(userId);
        }