static void Main(string[] args) { List <User> userList = new List <User>(); UserManagement userMan = new UserManagement(); userList.Add(userMan.AddUser("Ponkie", "Dino", "Reyes", "Huehuehue")); userList.Add(userMan.AddUser("Ponkiz", "Dinoa", "Reyesa", "Huehueaaahue")); userList.Add(userMan.AddUser("Ponkib", "Dinoa", "Reyesa", "Huehueaaahue")); displayList(userList); userMan.DeleteUser(userList, "Ponkiz"); displayList(userList); }
private void BtnSave_Click(object sender, EventArgs e) { if (VerifyData()) { List <String> PermissionArray = new List <String>(); for (int i = 0; i < UserPermissionType.RowCount; i++) { if (Convert.ToBoolean(UserPermissionType[0, i].Value)) { PermissionArray.Add(UserPermissionType[1, i].Value.ToString()); } } List <String> StationArray = new List <String>(); for (int i = 0; i < UserStationPermission.RowCount; i++) { if (Convert.ToBoolean(UserStationPermission[0, i].Value)) { StationArray.Add(UserStationPermission[1, i].Value.ToString()); } } if (UserID == null) { UserID = TTCSHelper.GenNewID(); UserManagement.AddUser(UserID, UserName.Text, UserLoginName.Text, UserLoginPassword.Text, String.Join(",", PermissionArray), String.Join(",", StationArray)); } else { UserManagement.UpdateUser(UserID, UserName.Text, UserLoginName.Text, UserLoginPassword.Text, String.Join(",", PermissionArray), String.Join(",", StationArray)); } this.Close(); } }
public ActionResult AddUser(EditUserDTO user, int inActive) { var validationIds = new List <string>(); var validationMessage = Validate(user, true, out validationIds); if (!validationMessage.Any()) { UserManagement.AddUser(user.ToUser()); } var users = UserManagement.GetAllUserList(); if (inActive == 0) { users = users.Where(x => x.IsDeleted == false); } else if (inActive == 1) { users = users.Where(x => x.IsDeleted); } var totalUsersPage = (int)Math.Ceiling(((double)users.Count() / (double)pageSize)); return(Json(new { users = ApplyPaging(users, 1), passed = !validationMessage.Any(), validationIds, totalUsersPage, validationMessage = string.Join("</br>", validationMessage) })); }
public ActionResult RegisterUser(string UserName, string Email, string sifre1, string sifre2) { if (Session["Login"] != null) { return(RedirectToAction("Index", "Home")); } else { if (string.IsNullOrEmpty(UserName) && string.IsNullOrEmpty(Email) && string.IsNullOrEmpty(sifre1) && string.IsNullOrEmpty(sifre2)) { ViewBag.sifrehata = "Eksik bilgiler var"; return(View()); } else { if (userManagement.AddUserEmailControl(Email) == null) { if (userManagement.AddUserUserNameControl(UserName) == null) { if (sifre1 == sifre2) { if (sifre1.Length < 8) { ViewBag.sifrehata = "Şifreniz 8 Karakterden Kısa Olamaz"; return(View()); } else { userManagement.AddUser(UserName, sifre1, Email); userManagement.EmailWelcomeSend(Email, UserName); } } else { ViewBag.sifrehata = "Şifreniz Hatalı"; return(View()); } } else { ViewBag.sifrehata = "Kullanıcı Adı Kullanımda"; return(View()); } } else { ViewBag.sifrehata = "Mail Adresi Kullanımda"; return(View()); } return(RedirectToAction("LoginUser", "Home")); } } }
static void Main(string[] args) { UserManagement userMan = new UserManagement(); string firstName, lastName, username; username = Console.ReadLine(); firstName = Console.ReadLine(); lastName = Console.ReadLine(); userMan.AddUser(username, firstName, lastName); }
public JsonResult PostAction() { var output = new Dictionary <string, string>(); JsonResult jsonOutput; try { var userobj = new User { FirstName = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(Request["firstname"]), LastName = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(Request["lastname"]), UserName = Request["username"].ToLower(), Email = Request["emailid"].ToLower() }; userobj.DisplayName = (userobj.FirstName.Trim() + " " + userobj.LastName.Trim()).Trim(); userobj.Password = "******"; userobj.CreatedDate = DateTime.UtcNow; userobj.ModifiedDate = DateTime.UtcNow; userobj.TimeZone = GlobalAppSettings.SystemSettings.TimeZone; userobj.IsActivated = false; userobj.IsActive = false; userobj.IsDeleted = false; var activationCode = String.Empty; var activationExpirationDate = new DateTime(); var result = userDetails.AddUser(userobj, out activationExpirationDate, out activationCode); if (result.Status) { var activationUrl = GlobalAppSettings.SystemSettings.BaseUrl + "/accounts/activate?ActivationCode=" + activationCode; const bool isResendActivationCode = false; UserManagementModel.SendActivationCode(userobj.FirstName, userobj.UserName, userobj.Email, activationUrl, activationExpirationDate, isResendActivationCode); output.Add("result", "success"); jsonOutput = Json(new { Data = output }); } else { output.Add("result", "error"); jsonOutput = Json(new { Data = output }); } } catch (Exception) { output.Add("result", "error"); jsonOutput = Json(new { Data = output }); } return(jsonOutput); }
private void OnAdd(PasswordBox passwordBox) { bool hasEnteredDetails = !string.IsNullOrEmpty(NewUserName) && !string.IsNullOrEmpty(passwordBox.Password); bool exists = UserManagement.UserExists(Repository, NewUserName); if (!hasEnteredDetails || exists || Repository.FirstOrDefault(t => string.Equals(t.Username, NewUserName)) != null) { MessageBoxHelper.ShowError(Resources.TXT_ERR_ENTER_UNIQUE_USERNAME); return; } UserManagement.AddUser(Repository, NewUserName, passwordBox.Password); Users = new ObservableCollection <User>(Repository.GetAll()); OnClear(passwordBox); }
public User AddUser(User user) { User addedUser = null; if (user == null) { return(null); } if (user.Firstname.Length > 50) { return(null); } addedUser = userManagment.AddUser(user); userManagment.UserChangeSave(); return(addedUser); }
public void AddUser_ShouldAddUser(string username, string firstName, string lastName, string password) { //userList.Add(userMan.AddUser(username, firstName, lastName, password)); //var expected = new User(); //expected.EntityID = 1; //expected.Username = username; //expected.FirstName = firstName; //expected.LastName = lastName; //expected.Password = password; //Assert.Contains(expected, userList); int actual = 0; userList.Add(userMan.AddUser(username, firstName, lastName, password)); int expected = 1; actual = userList.Count; Assert.Equal(expected, actual); }
public bool AddUser(UserRowData user) { bool success = false; using (var service = new UserManagement()) { try { var newUser = new UserDetail { UserName = user.UserName, DisplayName = user.DisplayName, Enabled = user.Enabled, CreationTime = Platform.Time, PasswordExpiryTime = Platform.Time, EmailAddress = user.EmailAddress, ResetPassword = true // TODO: Why do we need to reset password here? }; var groups = new List <AuthorityGroupSummary>(); foreach (UserGroup userGroup in user.UserGroups) { groups.Add(new AuthorityGroupSummary(new EntityRef(userGroup.UserGroupRef), userGroup.Name, userGroup.Name, false, false)); } newUser.AuthorityGroups = groups; service.AddUser(newUser); success = true; } catch (Exception ex) { Platform.Log(LogLevel.Error, ex, "Unexpected exception adding user: {0}", user.DisplayName); } } return(success); }
private void CreateUser(string lastName, string firstName, string username, string password, Role role) { try { _userManagement.AddUser(lastName, firstName, username, password, role); } catch (ArgumentNullException e) { throw e; } catch (UserExistsException e) { throw e; } catch (ServerUnavailableException e) { throw e; } catch (Exception e) { throw e; } }
protected void btnSignUp_Click(object sender, EventArgs e) { UserManagement _userManager = new UserManagement(); _userManager.AddUser(txtUserName.Text, txtMail.Text, txtPassword.Text, txtFirstName.Text, txtLastName.Text, txtCivilizationNumber.Text); }
/// <summary> /// Add System Admin /// </summary> /// <param name="userName">User name</param> /// <param name="firstName">Full name of user</param> /// <param name="lastName">Last name of user</param> /// <param name="emailId">Email Id</param> /// <param name="password">Password</param> public static void AddSystemAdmin(string userName, string firstName, string lastName, string emailId, string password) { LogExtension.LogInfo("Creating system admin", MethodBase.GetCurrentMethod()); var encrypt = new Cryptography(); var umpUser = new User(); var userManagement = new UserManagement(GlobalAppSettings.QueryBuilder, GlobalAppSettings.DataProvider); var groupManagement = new GroupManagement(GlobalAppSettings.QueryBuilder, GlobalAppSettings.DataProvider); umpUser.Password = Convert.ToBase64String(encrypt.Encryption(password)); umpUser.CreatedDate = DateTime.UtcNow; umpUser.ModifiedDate = DateTime.UtcNow; umpUser.IsActive = true; umpUser.IsDeleted = false; umpUser.ResetPasswordCode = "default"; umpUser.ActivationCode = "default"; umpUser.UserName = userName; umpUser.FirstName = firstName.Trim(); umpUser.LastName = lastName.Trim(); umpUser.DisplayName = (umpUser.FirstName.Trim() + " " + umpUser.LastName.Trim()).Trim(); umpUser.Email = emailId; umpUser.IsActivated = true; var activationCode = String.Empty; var activationExpirationDate = new DateTime(); LogExtension.LogInfo("Adding user in user table", MethodBase.GetCurrentMethod()); var result = userManagement.AddUser(umpUser, out activationExpirationDate, out activationCode); if (result.Status) { LogExtension.LogInfo("Adding user in user table succesful", MethodBase.GetCurrentMethod()); LogExtension.LogInfo("Adding user in super admin group table", MethodBase.GetCurrentMethod()); var userGroup = groupManagement.AddUserInGroup(Convert.ToInt32(result.ReturnValue), 1); LogExtension.LogInfo("Is user added in super admin?" + userGroup, MethodBase.GetCurrentMethod()); //var permissionSet = new PermissionSet(); //permissionSet.AddPermissionToGroup(new Permission //{ // PermissionAccess = PermissionAccess.Create, // PermissionEntity = PermissionEntity.AllCategories, // TargetId = 1 //}); //permissionSet.AddPermissionToGroup(new Permission //{ // PermissionAccess = PermissionAccess.Create, // PermissionEntity = PermissionEntity.AllReports, // TargetId = 1 //}); //permissionSet.AddPermissionToGroup(new Permission //{ // PermissionAccess = PermissionAccess.Create, // PermissionEntity = PermissionEntity.AllSchedules, // TargetId = 1 //}); //permissionSet.AddPermissionToGroup(new Permission //{ // PermissionAccess = PermissionAccess.Create, // PermissionEntity = PermissionEntity.AllDataSources, // TargetId = 1 //}); //permissionSet.AddPermissionToGroup(new Permission //{ // PermissionAccess = PermissionAccess.Create, // PermissionEntity = PermissionEntity.AllFiles, // TargetId = 1 //}); } else { LogExtension.LogInfo("Error in adding user in user table", MethodBase.GetCurrentMethod()); } }
public User AddUser(User user) { var newUser = userManagement.AddUser(user); return(newUser); }