protected void btnCreateUser_Click(object sender, EventArgs e) { ISession s = this.Session["User?Session"] as ISession; using (ITransaction t = s.BeginTransaction()) { WebUser user = new WebUser(); user.Username = txtUsername.Text; user.EmailAddress = txtEmailAddress.Text; user.UserID = Guid.NewGuid(); user.IsActive = true; //user.CreatedBy = this.CurrentUser.UserID; //user.CreatedOn = DateTime.UtcNow; string hash = Hashing.GetMd5Hash(txtPassword.Text, "sadf"); user.PasswordHash = hash; s.Save(user); t.Commit(); } }
protected void btnCreateUser_Click(object sender, EventArgs e) { ISession s = this.CurrentWebSession; using (ITransaction t = s.BeginTransaction()) { DateTime now = DateTime.Now; WebUser user = new WebUser(); user.Username = txtUsername.Text; user.EmailAddress = txtEmailAddress.Text; user.UserID = Guid.NewGuid(); user.IsActive = true; //user.CreatedBy = this.CurrentUser.UserID; //user.CreatedOn = DateTime.UtcNow; WebUserInfo info = new WebUserInfo(); info.WebUser = user; info.FirstName = txtFirstName.Text; info.ID = Guid.NewGuid(); info.LastName = txtLastName.Text; info.LastLogin = DateTime.Now; info.PrimaryPhone = txtPrimaryPhone.Text; info.SecondaryPhone = txtSecondaryPhone.Text; info.Hosts = int.Parse(ddlNumberOfHosts.SelectedValue); info.MainSecurityConcern = ddlMainConcern.SelectedValue; info.Provider = ddlProvider.SelectedValue; info.PrimaryWebsite = txtPrimaryWebsite.Text; info.IsActive = true; string hash = Hashing.GetMd5Hash(txtPassword.Text, "sadf"); user.PasswordHash = hash; VerificationKey vkey = new VerificationKey(); vkey.ID = Guid.NewGuid(); vkey.Key = Guid.NewGuid(); vkey.IsActive = true; vkey.CreatedBy = Guid.Empty; vkey.CreatedOn = now; vkey.LastModifiedBy = Guid.Empty; vkey.LastModifiedOn = now; vkey.IsVerifed = true; vkey.IsSent = true; //sending below vkey.User = user; s.SaveOrUpdate(vkey); s.SaveOrUpdate(info); s.SaveOrUpdate(user); try { t.Commit(); } catch (Exception ex) { t.Rollback(); throw ex; } Response.Redirect("Login.aspx"); } }