Esempio n. 1
0
        public async Task <ActionResult> ShowAuditInfoUser_UserSelected(ActionWithUserSearchData data, string submitAction, string filterAsString, string foundUserIds)
        {
            if (!this.HttpContext.Session.HasSystemActionRights() || !this.HttpContext.Session.HasSystemActionRight(ActionRights.UserManagement))
            {
                return(RedirectToAction("Index", "Home"));
            }

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

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

            if (data.FindUserData.SelectedUserIDs == null || data.FindUserData.SelectedUserIDs.Count <= 0 || string.IsNullOrWhiteSpace(foundUserIds))
            {
                return(await ShowAuditInfoUser_Find(data));
            }

            int selectedUserId   = data.FindUserData.SelectedUserIDs.FirstOrDefault();
            var auditDataForView = new ShowAuditInfoUserData(data.FindUserData)
            {
                AuditData   = await SecurityGuiHelper.GetAllAuditsForUserAsync(selectedUserId),
                AuditedUser = await UserGuiHelper.GetUserAsync(selectedUserId)
            };

            data.FindUserData.OverrideFilterAsString(filterAsString);

            // we'll keep the search form open so we can quickly view data of multiple users without searching again. This means we'll keep the finduserdata state
            // as it is, as this is the end state of this action anyway.
            data.FindUserData.ActionButtonText = "View audit info";
            data.FindUserData.FindUserState    = AdminFindUserState.UsersFound;
            var userIDsFoundAsString = foundUserIds.Split(',');
            var userIDsOfUsersToLoad = userIDsFoundAsString.Select(us => Convert.ToInt32(us)).ToList();

            data.FindUserData.FoundUsers = await UserGuiHelper.GetUsersAsync(userIDsOfUsersToLoad);

            return(View("~/Views/Admin/ShowAuditInfoUser.cshtml", auditDataForView));
        }