public static void ActivateUser(Cxt Cxt, string userName) { User user = User.GetUser(Cxt, userName); if (user.IsNew) { AppException.Throw("Msg.UserNameNotExists(userName)"); } switch (user.StatusIDE) { case StatusE.Active: AppException.Throw("Account is already active. <a href='http://RafeySoft.com/Web/Page/Account/SignIn.aspx'>Sign In</a> now!"); break; case StatusE.Disabled: AppException.Throw("Account is disabled."); break; case StatusE.Inactive: case StatusE.Deleted: user.StatusIDE = StatusE.Active; user.Save(); AppException.Throw("Account activated successfully. <a href='http://RafeySoft.com/Web/Page/Account/SignIn.aspx'>Sign In</a> now!"); break; } }
public static void SendActivationEmail(Cxt cxt, string userName) { User user = User.GetUser(cxt, userName); if (user.IsNew) { AppException.Throw("Msg.UserNameNotExists(userName)"); } MailVerifyResult result = EmailTemplate.Send(cxt, EmailTemplateE.NewAccount, user); if (result == MailVerifyResult.Ok) { AppException.Throw("Msg.ActivationEmailOk(userName)"); } }
protected override void Save(string connectionString, SqlTransaction t) { bool isNew = false; if (IsNew) { if (Exists(Cxt, UserName)) { AppException.Throw("Msg.UserNameExists(UserName)"); } this.StatusIDE = StatusE.Active; isNew = true; } try { //CalculateRanks(); if (t == null) { t = SqlHelper.BeginTransaction(connectionString); } base.Save(connectionString, t); if (isNew) { #region Save User Role UserRole ur = new UserRole(); ur.Cxt = Cxt; ur.UserID = ID; ur.RoleIDE = this.IsGuest ? RoleE.Guest : RoleE.Player; ur.Save(t); #endregion if (!this.IsGuest) { #region Email send MailVerifyResult mvr = EmailTemplate.Send(base.Cxt, EmailTemplateE.NewAccount, this); if (mvr != MailVerifyResult.Ok) { } #endregion } //UMail.Send(this, MailTemplateE.ActivateAccount); } SqlHelper.CommitTransaction(t); } catch (Exception ex) { SqlHelper.RollbackTransaction(t); throw ex; } }