protected void btnAddUser_Click(object sender, EventArgs e) { lblError.Text = ""; var sb = new StringBuilder("<ul>"); var errorFound = false; if (txtPassword.Text.Length < 6 && !cbxAutoPass.Checked) { errorFound = true; sb.AppendLine("<li><b>A Password of 6 characters or more is required or Autogenerate must be checked!</b></li>"); } var pass = cbxAutoPass.Checked ? Guid.NewGuid().ToString().Substring(0, 10) : txtPassword.Text; if (!StringHelper.IsValidEmail(txtEmail.Text)) { errorFound = true; sb.AppendLine("<li><b>The Email Address entered is not in a valid email address format!</b></li>"); } if (ddlUserType.SelectedValue == "" || int.Parse(ddlUserType.SelectedValue) > 3 || int.Parse(ddlUserType.SelectedValue) < 1) { errorFound = true; sb.AppendLine("<li><b>You must choose an Account Type</b></li>"); } lblError.Text = sb.ToString() + "</ul>"; if (errorFound) { return; } try { var user = new RollingRides.WebApp.Components.Datalayer.Models.User { Password = txtPassword.Text, Username = txtUsername.Text, Email = txtEmail.Text, AccountType = int.Parse(ddlUserType.SelectedValue), DateJoined = DateTime.Now, State = "IL", City = "", ZipCode = "", Street1 = "", Street2 = "", CompanyName = "", Expires = ddlUserType.SelectedValue == ((int)UserType.Corporate).ToString() ? DateTime.Now.AddDays(31) : (DateTime?)null, FirstName = "", LastName = "", PhoneNumber = "" }; _userManager.AddUpdate(user, UserType.Admin); BindOriginalData(); BindData(); } catch (Exception ex) { lblError.Text = ex.Message; } }
protected void btnAddUser_Click(object sender, EventArgs e) { lblError.Text = ""; var sb = new StringBuilder("<ul>"); var errorFound = false; if(txtPassword.Text.Length < 6 && !cbxAutoPass.Checked) { errorFound = true; sb.AppendLine("<li><b>A Password of 6 characters or more is required or Autogenerate must be checked!</b></li>"); } var pass = cbxAutoPass.Checked ? Guid.NewGuid().ToString().Substring(0, 10) : txtPassword.Text; if(!StringHelper.IsValidEmail(txtEmail.Text)) { errorFound = true; sb.AppendLine("<li><b>The Email Address entered is not in a valid email address format!</b></li>"); } if(ddlUserType.SelectedValue == "" || int.Parse(ddlUserType.SelectedValue) > 3 || int.Parse(ddlUserType.SelectedValue) < 1) { errorFound = true; sb.AppendLine("<li><b>You must choose an Account Type</b></li>"); } lblError.Text = sb.ToString() + "</ul>"; if(errorFound) { return; } try { var user = new RollingRides.WebApp.Components.Datalayer.Models.User { Password = txtPassword.Text, Username = txtUsername.Text, Email = txtEmail.Text, AccountType = int.Parse(ddlUserType.SelectedValue), DateJoined = DateTime.Now, State = "IL", City = "", ZipCode = "", Street1 = "", Street2 = "", CompanyName = "", Expires = ddlUserType.SelectedValue == ((int)UserType.Corporate).ToString() ? DateTime.Now.AddDays(31) : (DateTime?) null, FirstName = "", LastName = "", PhoneNumber = "" }; _userManager.AddUpdate(user, UserType.Admin); BindOriginalData(); BindData(); } catch(Exception ex) { lblError.Text = ex.Message; } }