protected void Save_OnClick(object sender, EventArgs e) { if (!canAccessSection) { return; } if (SelectedItem == null) { SelectedItem = UsersMapper.CreateObject(); } else { SelectedItem = BaseMapper.GetObjectFromContext <User>(SelectedItem); } SelectedItem.AuthenticationType = AuthType.Forms.ToString(); SelectedItem.ResetCode = ""; UpdateObjectFromFields(); Return returnObj = SelectedItem.Validate(); if (!returnObj.IsError) { if (SelectedItem.ID == 0) { returnObj = UsersMapper.Insert(SelectedItem); } else { returnObj = UsersMapper.Update(SelectedItem); } } if (returnObj.IsError) { DisplayErrorMessage("Error Saving Item", returnObj.Error); } else { DisplaySuccessMessage("Successfully Saved Item"); } }
protected void Create_OnClick(object sender, EventArgs e) { var newUser = UsersMapper.CreateObject(); newUser.UserName = EmailAddress.Text; newUser.EmailAddress = EmailAddress.Text; newUser.Password = Password.Text; newUser.AuthenticationType = AuthType.Forms.ToString(); newUser.IsActive = true; /*var role = RoleEnum.FrontEndUser; * RoleEnum.TryParse(Category.Text, out role); * * newUser.Roles.Add(BaseMapper.GetObjectFromContext(RolesMapper.GetByEnum(role)));*/ var returnObj = newUser.Validate(); var userExists = UsersMapper.GetByEmailAddress(newUser.EmailAddress); if (userExists != null) { returnObj.Error = ErrorHelper.CreateError("Validation Error", "An account with the same email address already exists, <a href=" + URIHelper.BaseUrl + "login>Click Here</a> to login or retrieve your password"); } if (!returnObj.IsError) { returnObj = UsersMapper.Insert(newUser); } if (returnObj.IsError) { Message.Text = returnObj.Error.Exception.Message; if ((returnObj.Error.Exception.InnerException.Message != null) && (returnObj.Error.Exception.InnerException.Message != "")) { Message.Text = returnObj.Error.Exception.InnerException.Message; } } else { var returnObjAutoResponder = SendAutoResponderEmail(newUser); var returnObjNotification = SendNotificationEmails(newUser); Response.Redirect(URIHelper.GetCurrentVirtualPath() + "thank-you/"); } }