public UserInfo(User user) { if (user == null) return; this.Id = user.Id; this.Username = user.Username; this.DisplayName = user.DisplayName; }
public void ActivateUser(User user, string password) { string customerSupportEmail = systemService.GetConfig<string>(Constants.Settings.CustomerSupportEmail, "*****@*****.**"); string emailTemplatePath = Path.Combine(this.emailTemplatesFolder, string.Format("{0}.xml", "ApprovedUser")); ParameterCollection parameters = new ParameterCollection(); parameters.Add("FromMail", customerSupportEmail); parameters.Add("ToMail", user.Email); parameters.Add("Username", user.Username); parameters.Add("Password", password); EmailTemplate emailTemplate = EmailUtility.ComposeTemplate(emailTemplatePath, parameters); emailSender.Send(emailTemplate, new BypassEmailFormatter(), null); }
public EditUserInfo(User user) : this() { this.Id = user.Id; this.Username = user.Username; this.FirstName = user.FirstName; this.LastName = user.LastName; this.Gender = user.Gender; this.DateOfBirth = user.DateOfBirth; this.HomePhone = user.HomePhone; this.MobilePhone = user.MobilePhone; this.Image = user.Image; this.Group = user.Group; this.GroupId = user.Group.Id; }
public void ChangeEmail(User user) { string customerSupportEmail = systemService.GetConfig<string>(Constants.Settings.CustomerSupportEmail, "*****@*****.**"); string emailTemplatePath = Path.Combine(this.emailTemplatesFolder, string.Format("{0}.xml", "ChangeEmail")); ParameterCollection parameters = new ParameterCollection(); parameters.Add("FromMail", customerSupportEmail); parameters.Add("ToMail", user.Email); parameters.Add("Username", user.Username); string emailBase64String = Convert.ToBase64String(System.Text.Encoding.Unicode.GetBytes(user.Email)); string activateAccountUrl = systemService.GetConfig<string>(Constants.Settings.BaseUrl, ""); activateAccountUrl = System.Text.RegularExpressions.Regex.Replace(activateAccountUrl, @"[a-z]{2}\-[A-Z]{2}", Thread.CurrentThread.CurrentCulture.Name); parameters.Add("Url", string.Format("{0}/home/changeemail/{1}", activateAccountUrl.Trim('/'), emailBase64String)); EmailTemplate emailTemplate = EmailUtility.ComposeTemplate(emailTemplatePath, parameters); emailSender.Send(emailTemplate, new BypassEmailFormatter(), null); }
public void UpdateUser(User user) { User current = repository.GetById<User>(user.Id); current.FirstName = user.FirstName; current.LastName = user.LastName; current.Gender = user.Gender; current.DateOfBirth = user.DateOfBirth; current.HomePhone = user.HomePhone; current.MobilePhone = user.MobilePhone; if (user.Image != null) { int resId = UpdateResource(current.Image, user.Image); current.Image = repository.GetById<Resource>(resId); } repository.Update(current); }
public void CreateUserByAdmin(User user) { if (repository.Exists<User>(u => u.Email == user.Email.ToLower())) { throw new BusinessException("The '" + user.Email + "' email is existing in the system"); } if (repository.Exists<User>(u => u.Username == user.Username.ToLower())) { throw new BusinessException("The '" + user.Username + "' username is existing in the system"); } string password = user.Password; user.Password = passwordEncryptor.Encrypt(user.Password); user.Email = user.Email.ToLower(); user.Username = user.Username.ToLower(); user.Group = GetGroupById(user.Group.Id); if (user.Image != null) { resourceService.CreateResource(user.Image); user.Image = resourceService.GetResourceById(user.Image.Id); } repository.Create(user); notificationService.CreateUser(user, password); }
public void CreateUser(User user) { if (repository.Exists<User>(u => u.Email == user.Email.ToLower())) { throw new BusinessException("The '" + user.Email + "' email is existing in the system"); } if (repository.Exists<User>(u => u.Username == user.Username.ToLower())) { throw new BusinessException("The '" + user.Username + "' username is existing in the system"); } string password = user.Password; if (string.IsNullOrEmpty(password)) { password = TextUtility.GeneratePassword(8); user.Password = password; } user.Password = passwordEncryptor.Encrypt(user.Password); user.Email = user.Email.ToLower(); user.Username = user.Username.ToLower(); user.Status = UserStatus.Inactive; repository.Create(user); notificationService.CreateUser(user, password); }
public void CreateManager(User user) { user.Group = GetGroupByName(Groups.Guests); CreateUser(user); }
public void CreateAdminUser(User user) { user.Group = GetGroupByName(Groups.Administrators); user.Status = UserStatus.Active; CreateUser(user); }
public User ToUser() { User user = new User(); user.Id = this.Id; user.FirstName = this.FirstName; user.LastName = this.LastName; user.Gender = this.Gender; user.DateOfBirth = this.DateOfBirth; user.HomePhone = this.HomePhone; user.MobilePhone = this.MobilePhone; user.Group = new Group() { Id = this.GroupId }; user.Status = this.Active ? UserStatus.Active : UserStatus.Inactive; return user; }
public User ToCreateUser() { User user = new User(); user.Username = this.Username; user.Email = this.Email; user.Password = this.Password; user.FirstName = this.FirstName; user.LastName = this.LastName; user.Gender = this.Gender; user.DateOfBirth = this.DateOfBirth; user.HomePhone = this.HomePhone; user.MobilePhone = this.MobilePhone; user.Group = new Group() { Id = this.GroupId }; user.Status = this.Active ? UserStatus.Active : UserStatus.Inactive; return user; }