Ejemplo n.º 1
0
        public JsonResult SaveUserProfileJSON(string OldUserName, string UserNameEmail, bool Inactive)
        {
            MembershipUser mu = Provider.GetUser(OldUserName, false);

            //Check to see if the old and new names are the same
            if (OldUserName != UserNameEmail)
            {
                if (Membership.GetUser(UserNameEmail) != null)
                {
                    return(new JsonResult {
                        Data = new { success = false, error = "New User Name / Email already exists!" }
                    });
                }

                mu.Email      = UserNameEmail;
                mu.IsApproved = !Inactive;
                Membership.UpdateUser(mu);

                UsersDataContext dc = new UsersDataContext();
                dc.S1_Users_ModifyUserName(OldUserName, UserNameEmail);

                return(new JsonResult {
                    Data = new { success = true, error = "User Name / Email changed!" }
                });
            }

            mu.IsApproved = !Inactive;
            Membership.UpdateUser(mu);

            //The names are the same, no change required
            return(new JsonResult {
                Data = new { success = true, error = "Changes Saved!" }
            });
        }