public async Task <IViewComponentResult> InvokeAsync(int pageNumber, string tab) { if (pageNumber > 0) { pageNumber -= 1; } var pageSize = _forumSettings.PrivateMessagesPageSize; var list = await _forumService.GetAllPrivateMessages(_storeContext.CurrentStore.Id, _workContext.CurrentCustomer.Id, "", null, false, null, string.Empty, pageNumber, pageSize); var sentItems = new List <PrivateMessageModel>(); foreach (var pm in list) { var fromCustomer = await _customerService.GetCustomerById(pm.FromCustomerId); var toCustomer = await _customerService.GetCustomerById(pm.ToCustomerId); sentItems.Add(new PrivateMessageModel { Id = pm.Id, FromCustomerId = fromCustomer.Id, CustomerFromName = fromCustomer.FormatUserName(_customerSettings.CustomerNameFormat), AllowViewingFromProfile = _customerSettings.AllowViewingProfiles && fromCustomer != null && !fromCustomer.IsGuest(), ToCustomerId = toCustomer.Id, CustomerToName = toCustomer.FormatUserName(_customerSettings.CustomerNameFormat), AllowViewingToProfile = _customerSettings.AllowViewingProfiles && toCustomer != null && !toCustomer.IsGuest(), Subject = pm.Subject, Message = pm.Text, CreatedOn = _dateTimeHelper.ConvertToUserTime(pm.CreatedOnUtc, DateTimeKind.Utc), IsRead = pm.IsRead, }); } var pagerModel = new PagerModel(_localizationService) { PageSize = list.PageSize, TotalRecords = list.TotalCount, PageIndex = list.PageIndex, ShowTotalSummary = false, RouteActionName = "PrivateMessagesPaged", UseRouteLinks = true, RouteValues = new PrivateMessageRouteValues { pageNumber = pageNumber, tab = tab } }; var model = new PrivateMessageListModel { Messages = sentItems, PagerModel = pagerModel }; return(View(model)); }
public ActionResult Inbox(int page, string tab) { if (page > 0) { page -= 1; } var pageSize = _forumSettings.PrivateMessagesPageSize; var list = _forumService.GetAllPrivateMessages(_storeContext.CurrentStore.Id, "", _workContext.CurrentCustomer.Id, null, null, false, string.Empty, page, pageSize); var inbox = new List <PrivateMessageModel>(); foreach (var pm in list) { var fromCustomer = _customerService.GetCustomerById(pm.FromCustomerId); var toCustomer = _customerService.GetCustomerById(pm.ToCustomerId); inbox.Add(new PrivateMessageModel { Id = pm.Id, FromCustomerId = fromCustomer.Id, CustomerFromName = fromCustomer.FormatUserName(), AllowViewingFromProfile = _customerSettings.AllowViewingProfiles && fromCustomer != null && !fromCustomer.IsGuest(), ToCustomerId = toCustomer.Id, CustomerToName = toCustomer.FormatUserName(), AllowViewingToProfile = _customerSettings.AllowViewingProfiles && toCustomer != null && !toCustomer.IsGuest(), Subject = pm.Subject, Message = pm.Text, CreatedOn = _dateTimeHelper.ConvertToUserTime(pm.CreatedOnUtc, DateTimeKind.Utc), IsRead = pm.IsRead, }); } var pagerModel = new PagerModel { PageSize = list.PageSize, TotalRecords = list.TotalCount, PageIndex = list.PageIndex, ShowTotalSummary = false, RouteActionName = "PrivateMessagesPaged", UseRouteLinks = true, RouteValues = new PrivateMessageRouteValues { page = page, tab = tab } }; var model = new PrivateMessageListModel { Messages = inbox, PagerModel = pagerModel }; return(PartialView(model)); }
public ActionResult SentItems(int page, string tab) { if (page > 0) { page -= 1; } var pageSize = _forumSettings.PrivateMessagesPageSize; var list = _forumService.GetAllPrivateMessages(_workContext.CurrentCustomer.Id, 0, null, false, null, string.Empty, page, pageSize); var sentItems = new List <PrivateMessageModel>(); foreach (var pm in list) { sentItems.Add(new PrivateMessageModel() { Id = pm.Id, FromCustomerId = pm.FromCustomer.Id, CustomerFromName = pm.FromCustomer.FormatUserName(), AllowViewingFromProfile = _customerSettings.AllowViewingProfiles && pm.FromCustomer != null && !pm.FromCustomer.IsGuest(), ToCustomerId = pm.ToCustomer.Id, CustomerToName = pm.ToCustomer.FormatUserName(), AllowViewingToProfile = _customerSettings.AllowViewingProfiles && pm.ToCustomer != null && !pm.ToCustomer.IsGuest(), Subject = pm.Subject, Message = pm.Text, CreatedOnUtc = pm.CreatedOnUtc, IsRead = pm.IsRead, }); } var pagerModel = new PagerModel() { PageSize = list.PageSize, TotalRecords = list.TotalCount, PageIndex = list.PageIndex, ShowTotalSummary = false, RouteActionName = "PrivateMessagesPaged", UseRouteLinks = true, RouteValues = new PrivateMessageRouteValues { page = page, tab = tab } }; var model = new PrivateMessageListModel() { Messages = sentItems, PagerModel = pagerModel }; return(PartialView(model)); }
public ActionResult Inbox(int page, string tab) { if (page > 0) { page -= 1; } var pageSize = _forumSettings.PrivateMessagesPageSize; var list = _forumService.GetAllPrivateMessages(0, _workContext.CurrentCustomer.Id, null, null, false, string.Empty, page, pageSize); var inbox = new List <PrivateMessageModel>(); foreach (var pm in list) { inbox.Add(new PrivateMessageModel() { customerFromName = pm.FromCustomer.FormatUserName(), customerToName = pm.ToCustomer.FormatUserName(), Subject = pm.Subject, Message = pm.Text, CreatedOnUtc = pm.CreatedOnUtc, Id = pm.Id, IsRead = pm.IsRead, }); } var pagerModel = new PagerModel() { PageSize = list.PageSize, TotalRecords = list.TotalCount, PageIndex = list.PageIndex, ShowTotalSummary = false, RouteActionName = "PrivateMessagesPaged", UseRouteLinks = true, RouteValues = new PrivateMessageRouteValues { page = page, tab = tab } }; var model = new PrivateMessageListModel() { Messages = inbox, PagerModel = pagerModel }; return(PartialView(model)); }
public ActionResult Inbox(int page, string tab) { if (page > 0) { page -= 1; } var pageSize = _forumSettings.PrivateMessagesPageSize; var list = _forumService.GetAllPrivateMessages( _storeContext.CurrentStore.Id, 0, _workContext.CurrentCustomer.Id, null, null, false, string.Empty, page, pageSize); var inbox = new List <PrivateMessageModel>(); foreach (var pm in list) { inbox.Add(new PrivateMessageModel { Id = pm.Id, FromCustomerId = pm.FromCustomer.Id, CustomerFromName = pm.FromCustomer.FormatUserName(), AllowViewingFromProfile = _customerSettings.AllowViewingProfiles && pm.FromCustomer != null && !pm.FromCustomer.IsGuest(), ToCustomerId = pm.ToCustomer.Id, CustomerToName = pm.ToCustomer.FormatUserName(), AllowViewingToProfile = _customerSettings.AllowViewingProfiles && pm.ToCustomer != null && !pm.ToCustomer.IsGuest(), Subject = pm.Subject, Message = pm.Text, CreatedOn = _dateTimeHelper.ConvertToUserTime(pm.CreatedOnUtc, DateTimeKind.Utc), IsRead = pm.IsRead, }); } ViewData["PagerRouteValues"] = new PrivateMessageRouteValues { page = page, tab = tab }; var model = new PrivateMessageListModel(list) { Messages = inbox }; return(PartialView(model)); }
/// <summary> /// Prepare the sent model /// </summary> /// <param name="page">Number of items page</param> /// <param name="tab">Tab name</param> /// <returns> /// A task that represents the asynchronous operation /// The task result contains the private message list model /// </returns> public virtual async Task <PrivateMessageListModel> PrepareSentModelAsync(int page, string tab) { if (page > 0) { page -= 1; } var pageSize = _forumSettings.PrivateMessagesPageSize; var messages = new List <PrivateMessageModel>(); var store = await _storeContext.GetCurrentStoreAsync(); var customer = await _workContext.GetCurrentCustomerAsync(); var list = await _forumService.GetAllPrivateMessagesAsync(store.Id, customer.Id, 0, null, false, null, string.Empty, page, pageSize); foreach (var pm in list) { messages.Add(await PreparePrivateMessageModelAsync(pm)); } var pagerModel = new PagerModel(_localizationService) { PageSize = list.PageSize, TotalRecords = list.TotalCount, PageIndex = list.PageIndex, ShowTotalSummary = false, RouteActionName = "PrivateMessagesPaged", UseRouteLinks = true, RouteValues = new PrivateMessageRouteValues { pageNumber = page, tab = tab } }; var model = new PrivateMessageListModel { Messages = messages, PagerModel = pagerModel }; return(model); }
/// <summary> /// Prepare the inbox model /// </summary> /// <param name="page">Number of items page</param> /// <param name="tab">Tab name</param> /// <returns>Private message list model</returns> public virtual PrivateMessageListModel PrepareInboxModel(int page, string tab) { if (page > 0) { page -= 1; } var pageSize = _forumSettings.PrivateMessagesPageSize; var messages = new List <PrivateMessageModel>(); var list = _forumService.GetAllPrivateMessages(_storeContext.CurrentStore.Id, 0, _workContext.CurrentCustomer.Id, null, null, false, string.Empty, page, pageSize); foreach (var pm in list) { messages.Add(PreparePrivateMessageModel(pm)); } var pagerModel = new PagerModel { PageSize = list.PageSize, TotalRecords = list.TotalCount, PageIndex = list.PageIndex, ShowTotalSummary = false, RouteActionName = "PrivateMessagesPaged", UseRouteLinks = true, RouteValues = new PrivateMessageRouteValues { pageNumber = page, tab = tab } }; var model = new PrivateMessageListModel { Messages = messages, PagerModel = pagerModel }; return(model); }