private void AddUser(appusers user) { if (UserExists(user)) throw new ArgumentException(TooManyUser); entities.appusers.AddObject(user); }
public void UpdateUser(appusers model) { model.lastLoginDate = DateTime.Now; model.lastActivityDate = DateTime.Now; entities.appusers.ApplyCurrentValues(model); Save(); }
public bool UserExists(appusers user) { if (user == null) return false; return (entities.appusers.SingleOrDefault(u => u.username == user.username) != null); }
public void DeleteUser(appusers model) { var rolesAsignadosParaBorrar = this.GetRolesForUser(model.username); foreach (approles rolToDelete in rolesAsignadosParaBorrar) model.approles.Remove(rolToDelete); entities.appusers.DeleteObject(model); this.Save(); }
public void EditUser(appusers model) { try { entities.appusers.Attach(model); entities.ObjectStateManager.ChangeObjectState(model, EntityState.Modified); Save(); } catch { throw new ArgumentException("The authentication provider returned an error. Please verify your entry and try again. " + "If the problem persists, please contact your system administrator."); } }
public void CreateUser(appusers newUser) { AddUser(newUser); Save(); }
public void DeleteRoleInUser(appusers ur, string role) { ur.approles.Remove(GetRole(role)); entities.appusers.ApplyCurrentValues(ur); this.Save(); }
public void CreateUser(string username, string password, string email, string passwordQuestion, string passwordAnswer, bool isApproved, object providerUserKey) { try { if (string.IsNullOrEmpty(username.Trim())) throw new ArgumentException("The user name provided is invalid. Please check the value and try again."); if (string.IsNullOrEmpty(password.Trim())) throw new ArgumentException("The name provided is invalid. Please check the value and try again."); if (string.IsNullOrEmpty(email.Trim())) throw new ArgumentException("The password provided is invalid. Please enter a valid password value."); if (this.entities.appusers.Any(user => user.username == username)) throw new ArgumentException("Username already exists. Please enter a different user name."); appusers newUser = new appusers() { username = username, password = FormsAuthentication.HashPasswordForStoringInConfigFile(password.Trim(), "md5"), email = email, lastActivityDate = DateTime.Now, creationDate = DateTime.Now, lastPasswordChangedDate = DateTime.Now }; AddUser(newUser); } catch (ArgumentException ae) { throw ae; } catch (Exception e) { throw new ArgumentException("The authentication provider returned an error. Please verify your entry and try again. " + "If the problem persists, please contact your system administrator."); } // Immediately persist the user data Save(); }
public void AsignarRolAUsuario(approles miRol, appusers miUser) { miUser.approles.Add(miRol); entities.appusers.ApplyCurrentValues(miUser); this.Save(); }
public override MembershipUser CreateUser(string username, string password, string email, string passwordQuestion, string passwordAnswer, bool isApproved, object providerUserKey, out MembershipCreateStatus status) { ValidatePasswordEventArgs args = new ValidatePasswordEventArgs(username, password, true); OnValidatingPassword(args); if (args.Cancel) { status = MembershipCreateStatus.InvalidPassword; return null; } if (RequiresUniqueEmail && GetUserNameByEmail(email) != "") { status = MembershipCreateStatus.DuplicateEmail; return null; } MembershipUser u = GetUser(username, false); if (u == null) { try { appusers newUser = new appusers(); newUser.username = username; newUser.password = EncodePassword(password); newUser.email = email; newUser.passwordQuestion = passwordQuestion; if (!string.IsNullOrEmpty(passwordAnswer)) newUser.passwordAnswer = EncodePassword(passwordAnswer); newUser.isApproved = Convert.ToByte(isApproved); newUser.creationDate = DateTime.Now; ApplicationService.CreateUser(newUser); status = MembershipCreateStatus.Success; return newUser.GetMembershipUser(PROVIDERNAME); } catch { //EventLog.WriteEntry(this.Name, e.Message); status = MembershipCreateStatus.UserRejected; return null; } } else { status = MembershipCreateStatus.DuplicateUserName; } return null; }
/// <summary> /// Deprecated Method for adding a new object to the appusers EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToappusers(appusers appusers) { base.AddObject("appusers", appusers); }
/// <summary> /// Create a new appusers object. /// </summary> /// <param name="username">Initial value of the username property.</param> /// <param name="password">Initial value of the password property.</param> /// <param name="email">Initial value of the email property.</param> /// <param name="isApproved">Initial value of the isApproved property.</param> /// <param name="isLockedOut">Initial value of the isLockedOut property.</param> public static appusers Createappusers(global::System.String username, global::System.String password, global::System.String email, global::System.Byte isApproved, global::System.Byte isLockedOut) { appusers appusers = new appusers(); appusers.username = username; appusers.password = password; appusers.email = email; appusers.isApproved = isApproved; appusers.isLockedOut = isLockedOut; return appusers; }