Example #1
0
        public async Task <ActionResult> EditUserInfo_FinalAction(EditUserInfoData data)
        {
            if (!this.HttpContext.Session.HasSystemActionRights() || !this.HttpContext.Session.HasSystemActionRight(ActionRights.UserManagement))
            {
                return(RedirectToAction("Index", "Home"));
            }

            data.UserTitles = await UserGuiHelper.GetAllUserTitlesAsync();

            data.Roles = await SecurityGuiHelper.GetAllRolesAsync();

            if (!ModelState.IsValid)
            {
                return(View("~/Views/Admin/EditUserInfo.cshtml", data));
            }

            data.Sanitize();
            data.StripProtocolsFromUrls();
            bool result = false;
            var  user   = await UserGuiHelper.GetUserAsync(data.UserId);

            if (user != null)
            {
                result = await UserManager.UpdateUserProfileAsync(data.UserId, data.DateOfBirth, data.EmailAddress, user.EmailAddressIsPublic ?? false, data.IconURL,
                                                                  data.Location, data.Occupation, data.NewPassword, data.Signature, data.Website, data.UserTitleId,
                                                                  user.AutoSubscribeToThread, user.DefaultNumberOfMessagesPerPage, data.IsBanned, data.RoleIDs);
            }

            data.InfoEdited = result;
            return(View("~/Views/Admin/EditUserInfo.cshtml", data));
        }
Example #2
0
        public async Task <ActionResult> EditUserInfo_UserSelected(ActionWithUserSearchData data, string submitAction)
        {
            if (!this.HttpContext.Session.HasSystemActionRights() || !this.HttpContext.Session.HasSystemActionRight(ActionRights.UserManagement))
            {
                return(RedirectToAction("Index", "Home"));
            }

            if (submitAction == "SearchAgain")
            {
                return(await EditUserInfo());
            }

            if (submitAction != "PerformAction")
            {
                return(RedirectToAction("Index", "Home"));
            }

            if (data.FindUserData.SelectedUserIDs == null || data.FindUserData.SelectedUserIDs.Count <= 0)
            {
                return(await EditUserInfo_Find(data));
            }

            var user = await UserGuiHelper.GetUserAsync(data.FindUserData.SelectedUserIDs.FirstOrDefault());

            if (user == null)
            {
                // not found
                return(RedirectToAction("Index", "Home"));
            }

            var newData = new EditUserInfoData()
            {
                UserId        = user.UserID,
                EmailAddress  = user.EmailAddress,
                NickName      = user.NickName,
                DateOfBirth   = user.DateOfBirth,
                Occupation    = user.Occupation ?? string.Empty,
                Location      = user.Location ?? string.Empty,
                Signature     = user.Signature ?? string.Empty,
                Website       = user.Website ?? string.Empty,
                IconURL       = user.IconURL ?? string.Empty,
                UserTitleId   = user.UserTitleID,
                IPAddress     = user.IPNumber,
                LastVisitDate = user.LastVisitedDate.HasValue ? user.LastVisitedDate.Value.ToString("f") : "Never",
                IsBanned      = user.IsBanned,
                RoleIDs       = await SecurityGuiHelper.GetAllRoleIDsForUserAsync(user.UserID),
                Roles         = await SecurityGuiHelper.GetAllRolesAsync(),
                UserTitles    = await UserGuiHelper.GetAllUserTitlesAsync(),
            };

            newData.Sanitize();
            return(View("~/Views/Admin/EditUserInfo.cshtml", newData));
        }