public void RegisterNewUser() { _userRoleService = new UserRoleService(); MD5 md5Hash = MD5.Create(); // var passwordPolicyConfigEntry = passwordPolicyConfigService.GetPasswordPolicyByUserType(UserType); //string password = passwordPolicyConfigEntry == null ? CommonMethods.RandomPassword(true, true, true, true, 9) : CommonMethods.RandomPassword(true, passwordPolicyConfigEntry.RequireUpperCase, passwordPolicyConfigEntry.RequiredNumericChar, passwordPolicyConfigEntry.RequireSpecialChar, passwordPolicyConfigEntry.MinLegth); /*CommonMethods.GeneratePassword();*/ string password = "******"; string ImagePath = ""; if (ImageFileBase != null) { var fileNameWithoutExt = Path.GetFileNameWithoutExtension(ImageFileBase.FileName); var fileExtension = Path.GetExtension(ImageFileBase.FileName); var finalFileName = Name + "_ProfileImage" + string.Format("{0:yyMMddhhmmss}", DateTime.Now) + fileExtension; string savePath = Path.Combine(HttpContext.Current.Server.MapPath("/Uploads/"), finalFileName); ImageFileBase.SaveAs(savePath); ImagePath = "/Uploads/" + finalFileName; } int? loggedInUserId = AuthenticatedUser.GetUserFromIdentity().UserId; User newUser = new User { Name = Name, UserName = UserName, Email = Email, Password = GetMd5Hash(md5Hash, password), MobileNumber = MobileNumber, PresentAddress = Address, Gender = Gender, SupUser = false, ImageFile = ImagePath, //DepartmentId = DepartmentId, //DesignationId = DesignationId, CardNo = CardNo, Status = 1, CreatedBy = loggedInUserId, UserType = UserType, EmployeeType = EmployeeType, RoleId = RoleId, //ExpireDate = EmployeeType != "Permanent" ? ExpireDate : null }; _userService.AddUser(newUser); //new MailerModel().SendRegistationMail(Email, "New User Registration for SCHM Application", Name, UserName, password, ConfigurationManager.AppSettings["WebUrl"].ToString()); }
public void EditUser() { _userRoleService = new UserRoleService(); string ImagePath = ""; int? loggedInUserId = AuthenticatedUser.GetUserFromIdentity().UserId; User updateUser = new User { Id = Id, Name = Name, UserName = UserName, Email = Email, MobileNumber = MobileNumber, PresentAddress = Address, Gender = Gender, //DepartmentId = DepartmentId, //DesignationId = DesignationId, CardNo = CardNo, RoleId = RoleId, UpdatedAt = DateTime.Now, UpdatedBy = loggedInUserId, UserType = UserType, EmployeeType = EmployeeType, //ExpireDate = EmployeeType != "Permanent" ? ExpireDate : null }; if (ImageFileBase != null) { var fileNameWithoutExt = Path.GetFileNameWithoutExtension(ImageFileBase.FileName); var fileExtension = Path.GetExtension(ImageFileBase.FileName); var finalFileName = Name + "_ProfileImage" + string.Format("{0:yyMMddhhmmss}", DateTime.Now) + fileExtension; string savePath = Path.Combine(HttpContext.Current.Server.MapPath("/Uploads/"), finalFileName); ImageFileBase.SaveAs(savePath); updateUser.ImageFile = "/Uploads/" + finalFileName; } _userService.EditUser(updateUser); }