public IEnumerable <DashboardVM> GetDashboard(IndexBody model) { IEnumerable <DashboardVM> dashboard = null; if (HttpContext.Current.User.IsInRole(Key.ROLE_ADMIN) || HttpContext.Current.User.IsInRole(Key.ROLE_STAFF)) { IEnumerable <DashboardVM> dashboardNotifications; if (String.IsNullOrEmpty(model.SearchString)) { dashboardNotifications = _context.Notification .Select(s => new DashboardVM() { IncidentNumber = s.IncidentNumber, LevelOfImpact = s.LevelOfImpact.LevelName, ImpactValue = s.LevelOfImpact.LevelValue, ThreadHeading = s.NotificationHeading, SentDateTime = s.SentDateTime, Status = s.Status.StatusName, SenderName = s.UserDetail.FirstName + " " + s.UserDetail.LastName }) .OrderBy(x => x.LevelOfImpact); } else { dashboardNotifications = _context.Notification.Where( n => n.IncidentNumber.ToLower().Contains(model.SearchString.ToLower()) || n.NotificationHeading.ToLower().Contains(model.SearchString.ToLower()) || n.NotificationDescription.ToLower().Contains(model.SearchString.ToLower()) // TODO: add more columns for large index search ) .Select(s => new DashboardVM() { IncidentNumber = s.IncidentNumber, LevelOfImpact = s.LevelOfImpact.LevelName, ImpactValue = s.LevelOfImpact.LevelValue, ThreadHeading = s.NotificationHeading, SentDateTime = s.SentDateTime, Status = s.Status.StatusName, SenderName = s.UserDetail.FirstName + " " + s.UserDetail.LastName }) .OrderBy(x => x.LevelOfImpact); } dashboard = dashboardNotifications .GroupBy(n => n.IncidentNumber) .Select( t => t.OrderByDescending(i => i.SentDateTime).FirstOrDefault()) .Where(n => n.Status != Key.STATUS_NOTIFICATION_CLOSED); } return(dashboard); }
public DashboardIndexFiltered GetFilteredAndSortedDasboard(IndexBody model) { var dashboardThreads = GetDashboard(model); IPagedList <DashboardVM> threads = Sort(dashboardThreads, model.CurrentSort).ToPagedList(model.Page, model.ItemsPerPage ?? ConstantsRepo.PAGE_SIZE); DashboardIndexFiltered result = new DashboardIndexFiltered() { ItemStart = (threads.PageNumber - 1) * threads.PageSize + 1, ItemEnd = threads.PageNumber * threads.PageSize < threads.TotalItemCount ? threads.PageNumber * threads.PageSize : threads.TotalItemCount, PageCount = threads.PageCount, PageNumber = threads.PageNumber, TotalItemsCount = threads.TotalItemCount, Threads = threads.ToList(), IDSort = model.CurrentSort == ConstantsRepo.SORT_NOTIFICATION_BY_ID_ASCE ? ConstantsRepo.SORT_NOTIFICATION_BY_ID_DESC : ConstantsRepo.SORT_NOTIFICATION_BY_ID_ASCE, SubjectSort = model.CurrentSort == ConstantsRepo.SORT_NOTIFICATION_BY_HEADING_DESC ? ConstantsRepo.SORT_NOTIFICATION_BY_HEADING_ASCE : ConstantsRepo.SORT_NOTIFICATION_BY_HEADING_DESC, SenderSort = model.CurrentSort == ConstantsRepo.SORT_NOTIFICATION_BY_SENDER_DESC ? ConstantsRepo.SORT_NOTIFICATION_BY_SENDER_ASCE : ConstantsRepo.SORT_NOTIFICATION_BY_SENDER_DESC, DateSort = model.CurrentSort == ConstantsRepo.SORT_NOTIFICATION_BY_DATE_DESC ? ConstantsRepo.SORT_NOTIFICATION_BY_DATE_ASCE : ConstantsRepo.SORT_NOTIFICATION_BY_DATE_DESC, LevelOfImpactSort = model.CurrentSort == ConstantsRepo.SORT_LEVEL_OF_IMPACT_DESC ? ConstantsRepo.SORT_LEVEL_OF_IMPACT_ASCE : ConstantsRepo.SORT_LEVEL_OF_IMPACT_DESC, }; return(result); }
// POST: api/Dashboard public DashboardIndexFiltered Post([FromBody] IndexBody model) { DashboardIndexFiltered result = _dApiRepo.GetFilteredAndSortedDasboard(model); return(result); }
static void Main(string[] args) { TextDocument doc = new TextDocument(); Paragraph tocParagraph = new Paragraph(); tocParagraph.Add("Table of Contents"); Paragraph p1 = new Paragraph(); p1.Add("First chapter"); p1.AddTab(); p1.Add("2"); Paragraph p2 = new Paragraph(); p2.Add("Second chapter"); p2.AddTab(); p2.Add("3"); IndexTitle indexTitle = new IndexTitle(); indexTitle.Content.Add(tocParagraph); IndexBody indexBody = new IndexBody(); indexBody.Content.Add(indexTitle); indexBody.Content.Add(new Paragraph()); //empty paragraph indexBody.Content.Add(p1); indexBody.Content.Add(p2); IndexTitleTemplate indexTitleTemplate = new IndexTitleTemplate(); indexTitleTemplate.Value = "Table of Contents"; TabStopIndexEntry tabStopIndexEntry = new TabStopIndexEntry(); tabStopIndexEntry.LeaderCharacter = "."; tabStopIndexEntry.Type = TabStopIndexEntryType.Right; TableOfContentsEntryTemplate entry1 = new TableOfContentsEntryTemplate(); entry1.OutlineLevel = 1; entry1.Content.Add(new ChapterIndexEntry()); entry1.Content.Add(new TextIndexEntry()); entry1.Content.Add(tabStopIndexEntry); entry1.Content.Add(new PageNumberIndexEntry()); TableOfContentsSource tocSource = new TableOfContentsSource(); tocSource.OutlineLevel = 10; tocSource.IndexTitleTemplate = indexTitleTemplate; tocSource.EntryTemplates.Add(entry1); TableOfContents toc = new TableOfContents(); toc.IsProtected = true; toc.IndexBody = indexBody; toc.Source = tocSource; Heading heading1 = new Heading(); heading1.Level = 1; heading1.Add("First chapter"); Heading heading2 = new Heading(); heading2.Level = 1; heading2.Add("Second chapter"); ParagraphStyle style1 = new ParagraphStyle("MyStyle"); style1.ParagraphProperties.BreakAfter = Break.Page; Paragraph pageBreakParagraph = new Paragraph(); pageBreakParagraph.Style = "MyStyle"; doc.AutomaticStyles.Styles.Add(style1); doc.Body.Add(toc); doc.Body.Add(pageBreakParagraph); doc.Body.Add(heading1); doc.Body.Add(pageBreakParagraph); doc.Body.Add(heading2); doc.Save("c:\\test\\output.odt", true); }