Esempio n. 1
0
        public async Task <ActionResult> ViewProfile(int userId = 0)
        {
            var userID = this.HttpContext.Session.GetUserID();

            if (userID <= 0 || userId == 0)
            {
                // not useful
                return(RedirectToAction("Index", "Home"));
            }

            var userProfileData = await UserGuiHelper.GetUserProfileInfoAsync(userId);

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

            var viewData = new UserProfileData()
            {
                ProfileDataFromDatabase = userProfileData
            };

            viewData.AdminSectionIsVisible = this.HttpContext.Session.HasSystemActionRight(ActionRights.SystemManagement) ||
                                             this.HttpContext.Session.HasSystemActionRight(ActionRights.SecurityManagement) ||
                                             this.HttpContext.Session.HasSystemActionRight(ActionRights.UserManagement);
            viewData.UserHasSystemManagementRight = this.HttpContext.Session.HasSystemActionRight(ActionRights.SystemManagement);
            viewData.LastThreads = await UserGuiHelper.GetLastThreadsForUserAggregatedDataAsync(this.HttpContext.Session.GetForumsWithActionRight(ActionRights.AccessForum), userId,
                                                                                                this.HttpContext.Session.GetForumsWithActionRight(ActionRights.ViewNormalThreadsStartedByOthers),
                                                                                                this.HttpContext.Session.GetUserID(), 25);

            viewData.CurrentlyLoggedInUserID = this.HttpContext.Session.GetUserID();
            return(View(viewData));
        }
Esempio n. 2
0
        public async Task <ActionResult> Threads(int pageNo = 1)
        {
            var userID = this.HttpContext.Session.GetUserID();

            if (userID <= 0)
            {
                // not found
                return(RedirectToAction("Index", "Home"));
            }

            int rowCount = this.HttpContext.Session.GetInt32(SessionKeys.MyThreadsRowCount) ?? 0;

            if (rowCount <= 0)
            {
                rowCount = await UserGuiHelper.GetRowCountLastThreadsForUserAsync(this.HttpContext.Session.GetForumsWithActionRight(ActionRights.AccessForum), userID,
                                                                                  this.HttpContext.Session.GetForumsWithActionRight(ActionRights.ViewNormalThreadsStartedByOthers),
                                                                                  userID);

                this.HttpContext.Session.SetInt32(SessionKeys.MyThreadsRowCount, rowCount);
            }

            var systemSettings = await _cache.GetSystemDataAsync();

            int pageSize = systemSettings.PageSizeSearchResults;

            if (pageSize <= 0)
            {
                pageSize = 50;
            }

            int rowCountCapped = rowCount;

            if (rowCount > 500)
            {
                // maximum is 500
                rowCountCapped = 500;
            }

            int numberOfPages = (rowCountCapped / pageSize);

            if ((numberOfPages * pageSize) < rowCountCapped)
            {
                numberOfPages++;
            }

            var data = new MyThreadsData()
            {
                RowCount = rowCount, NumberOfPages = numberOfPages, PageNo = pageNo
            };

            data.ThreadRows = await UserGuiHelper.GetLastThreadsForUserAggregatedDataAsync(this.HttpContext.Session.GetForumsWithActionRight(ActionRights.AccessForum), userID,
                                                                                           this.HttpContext.Session.GetForumsWithActionRight(ActionRights.ViewNormalThreadsStartedByOthers),
                                                                                           userID, pageSize, pageNo);

            return(View(data));
        }