public void RenderEmailFolders() { var html = new StringBuilder(); // Get the data var service = new MessagesService(); var folders = service.GetEmailFolders(); // Group the data var standardFolderTypes = new List<int> { 1, 2, 3, 4 }; var standardFolders = folders.Where(c => standardFolderTypes.Contains(c.MailFolderTypeID)); var personalFolderTypes = new List<int> { 0 }; var personalFolders = folders.Where(c => personalFolderTypes.Contains(c.MailFolderTypeID)); // Render the standard folders first html.AppendFormat("<ul class='nav nav-pills nav-stacked'>"); foreach(var folder in standardFolders) { // Determine if we have any uinread messages in this folder var hasUnreadMessages = folder.UnreadCount > 0; var cssClass = (hasUnreadMessages) ? "active" : string.Empty; var unreadCountDisplay = (hasUnreadMessages) ? string.Format(" ({0})", folder.UnreadCount) : string.Empty; // Render the list item html.AppendFormat("<li class='{0}'><a href='Messages.aspx?f={3}'>{1}{2}</a></li>", cssClass, folder.Name, unreadCountDisplay, folder.MailFolderID); } html.AppendFormat("</ul>"); // Render the personal folders next html.AppendFormat("<ul class='nav nav-pills nav-stacked'>"); foreach(var folder in personalFolders) { // Determine if we have any uinread messages in this folder var hasUnreadMessages = folder.UnreadCount > 0; var cssClass = (hasUnreadMessages) ? "active" : string.Empty; var unreadCountDisplay = (hasUnreadMessages) ? string.Format(" ({0})", folder.UnreadCount) : string.Empty; // Render the list item html.AppendFormat("<li class='{0}'><a href='Messages.aspx?f={3}'>{1}{2}</a></li>", cssClass, folder.Name, unreadCountDisplay, folder.MailFolderID); } html.AppendFormat("</ul>"); // Write the HTML to the screen var writer = new HtmlTextWriter(Response.Output); writer.Write(html.ToString()); }
public void RenderMoveToEmailFolders() { var html = new StringBuilder(); // Get the data var service = new MessagesService(); var folders = service.GetEmailFolders(); // Group the data var moveToFolderTypes = new List<int> { 0, 1 }; var mvoeToFolders = folders.Where(c => moveToFolderTypes.Contains(c.MailFolderTypeID)); // Render the personal folders next html.AppendFormat("<ul class='dropdown-menu'>"); if(mvoeToFolders.Count() > 0) { foreach(var folder in mvoeToFolders) { // Render the list item html.AppendFormat("<li><a href='javascript:;' onclick='messagelist.moveSelectedIDsToFolder({0})'>{1}</a></li>", folder.MailFolderID, folder.Name); } // Render the divider html.AppendFormat("<li class='divider'></li>"); } // Finally, render a 'Create new folder' link html.AppendFormat("<li><a href='javascript:;' onclick='folders.openCreateModal()'>Create new...</a></li>"); html.AppendFormat("</ul>"); // Write the HTML to the screen var writer = new HtmlTextWriter(Response.Output); writer.Write(html.ToString()); }