Ejemplo n.º 1
0
        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/");
            }
        }
Ejemplo n.º 2
0
        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");
            }
        }
Ejemplo n.º 3
0
        protected void Signup_Click(object sender, EventArgs e)
        {
            var returnObj = BaseMapper.GenerateReturn();

            var foundUser = UsersMapper.GetByEmailAddress(EmailAddress.Text);

            if (foundUser == null)
            {
                var user = new User();
                user.FirstName = FirstName.Text;
                user.LastName  = LastName.Text;
                user.UserName  = user.EmailAddress = EmailAddress.Text;

                user.SetPassword(Password.Text);

                user.AfterLoginStartPage = "";
                user.AuthenticationType  = AuthType.Forms.ToString();
                user.ResetCode           = "";

                if (!IsValid(user))
                {
                    returnObj = BaseMapper.GenerateReturn("Please make sure you fill out the required fields correctly");
                }
                else
                {
                    var role = RolesMapper.GetByEnum(RoleEnum.Member);

                    if (role != null)
                    {
                        user.Roles.Add(role);

                        var dashboard = MediaDetailsMapper.GetByMediaType(MediaTypeEnum.Dashboard).FirstOrDefault();

                        /*var level = dashboard.ChildMediaDetails.FirstOrDefault(i=>i.MediaType.Name == MediaTypeEnum.Level.ToString());
                         *
                         * if (level != null)
                         * {
                         *      user.UnlockMedia(level.Media);
                         * }*/

                        returnObj = UsersMapper.Insert(user);

                        if (!returnObj.IsError)
                        {
                            FormsAuthentication.SetAuthCookie(user.UserName, false);
                            FrameworkSettings.CurrentUser = user;

                            SendAutoResponderEmail(user);
                            //SendNotificationEmails(user);

                            if (BasePage.CurrentMediaDetail.ChildMediaDetails.Any())
                            {
                                var firstPageUrl = BasePage.CurrentMediaDetail.ChildMediaDetails.ElementAt(0).AbsoluteUrl;
                                Response.Redirect(firstPageUrl);
                            }
                        }
                    }
                }
            }
            else
            {
                returnObj = BaseMapper.GenerateReturn("A user with the same email address already exists in the system.");
            }

            if (returnObj.IsError)
            {
                ErrorPanel.Visible = true;
                ServerMessage.Text = returnObj.Error.Exception.Message;
            }
        }