public ActionResult Index(int?p) { if (LoggedOnReadOnlyUser.DisablePrivateMessages == true) { TempData[AppConstants.MessageViewBagName] = new GenericMessageViewModel { Message = LocalizationService.GetResourceString("Errors.NoPermission"), MessageType = GenericMessages.danger }; return(RedirectToAction("Index", "Home")); } using (UnitOfWorkManager.NewUnitOfWork()) { var pageIndex = p ?? 1; var pagedMessages = _privateMessageService.GetUsersPrivateMessages(pageIndex, SiteConstants.Instance.PrivateMessageListSize, LoggedOnReadOnlyUser); var viewModel = new ListPrivateMessageViewModel { Messages = pagedMessages, PageIndex = pageIndex, TotalCount = pagedMessages.TotalCount, TotalPages = pagedMessages.TotalPages }; return(View(viewModel)); } }
public async Task <ActionResult> Index(int?p) { var loggedOnReadOnlyUser = User.GetMembershipUser(MembershipService); var loggedOnUsersRole = loggedOnReadOnlyUser.GetRole(RoleService); if (loggedOnReadOnlyUser.DisablePrivateMessages == true) { TempData[AppConstants.MessageViewBagName] = new GenericMessageViewModel { Message = LocalizationService.GetResourceString("Errors.NoPermission"), MessageType = GenericMessages.danger }; return(RedirectToAction("Index", "Home")); } var pageIndex = p ?? 1; var pagedMessages = await _privateMessageService.GetUsersPrivateMessages(pageIndex, SiteConstants.Instance.PrivateMessageListSize, loggedOnReadOnlyUser); var viewModel = new ListPrivateMessageViewModel { Messages = pagedMessages, PageIndex = pageIndex, TotalCount = pagedMessages.TotalCount, TotalPages = pagedMessages.TotalPages }; return(View(viewModel)); }