Пример #1
0
        public static User ToDtoObject(this Trex.Server.Core.Model.User user, bool includeProjects)
        {
            var dtoUser = new User();

            dtoUser.UserName          = user.UserName;
            dtoUser.UserId            = user.Id;
            dtoUser.FullName          = user.Name;
            dtoUser.Inactive          = user.Inactive;
            dtoUser.Price             = user.Price;
            dtoUser.Email             = user.Email;
            dtoUser.CustomerInfo      = user.CustomerInfo.ToDtoObjects();
            dtoUser.NumOfTimeEntries  = user.NumOfTimeEntries;
            dtoUser.TotalTime         = user.TotalTime;
            dtoUser.TotalBillableTime = user.TotalBillableTime;


            if (includeProjects)
            {
                dtoUser.Projects = user.Projects.ToDtoObjects(false, false, false);
            }



            return(dtoUser);
        }
Пример #2
0
        protected void CreateUserClick(object sender, EventArgs e)
        {
            var userManagementService = ObjectFactory.GetInstance <IUserManagementService>();
            var newUser = new Trex.Server.Core.Model.User()
            {
                UserName = txtUserName.Text,
                Name     = txtFullName.Text,
                Email    = txtEmail.Text,
            };

            if (string.IsNullOrEmpty(roleList.SelectedValue))
            {
                status.Text = "Select a role";
                return;
            }

            var userCreationResponse = userManagementService.CreateUser(newUser, txtPassword.Text, "test", "test");

            if (userCreationResponse.Success)
            {
                Roles.AddUserToRole(txtUserName.Text, roleList.SelectedValue);
            }
            status.Text = userCreationResponse.Response;
        }