public NotificationIndexFiltered GetFilteredAndSortedNotifications(NotificationIndexBody model) { int value = model.NotificationTypeIDs.Length + model.LevelOfImpactIDs.Length + model.StatusIDs.Length + model.PriorityIDs.Length; IEnumerable <Thread> allThreads = value == 0 ? GetAllNotifications() : GetFilteredNotifications(model); IPagedList <Thread> threads = allThreads != null?Sort(allThreads, model.CurrentSort, model.SearchString).ToPagedList(model.Page, model.ItemsPerPage ?? ConstantsRepo.PAGE_SIZE) : new List <Thread>().ToPagedList(1, 1); NotificationIndexFiltered result = new NotificationIndexFiltered() { ItemStart = threads.TotalItemCount > 0 ? (threads.PageNumber - 1) * threads.PageSize + 1 : 0, 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(), IncidentNumberSort = model.CurrentSort == ConstantsRepo.SORT_INCIDENT_NUMBER_ASCE ? ConstantsRepo.SORT_INCIDENT_NUMBER_DESC : ConstantsRepo.SORT_INCIDENT_NUMBER_ASCE, LevelOfImpactSort = model.CurrentSort == ConstantsRepo.SORT_LEVEL_OF_IMPACT_DESC ? ConstantsRepo.SORT_LEVEL_OF_IMPACT_ASCE : ConstantsRepo.SORT_LEVEL_OF_IMPACT_DESC, NotificationHeadingSort = model.CurrentSort == ConstantsRepo.SORT_NOTIFICATION_BY_HEADING_ASCE ? ConstantsRepo.SORT_NOTIFICATION_BY_HEADING_DESC : ConstantsRepo.SORT_NOTIFICATION_BY_HEADING_ASCE, NotificationTypeSort = model.CurrentSort == ConstantsRepo.SORT_NOTIFICATION_BY_TYPE_ASCE ? ConstantsRepo.SORT_NOTIFICATION_BY_TYPE_DESC : ConstantsRepo.SORT_NOTIFICATION_BY_TYPE_ASCE, PrioritySort = model.CurrentSort == ConstantsRepo.SORT_NOTIFICATION_BY_PRIORITY_DESC ? ConstantsRepo.SORT_NOTIFICATION_BY_PRIORITY_ASCE : ConstantsRepo.SORT_NOTIFICATION_BY_PRIORITY_DESC, StatusSort = model.CurrentSort == ConstantsRepo.SORT_STATUS_BY_NAME_DESC ? ConstantsRepo.SORT_STATUS_BY_NAME_ASCE : ConstantsRepo.SORT_STATUS_BY_NAME_DESC }; return(result); }
// POST: api/Notification public NotificationIndexFiltered Post([FromBody] NotificationIndexBody model) { NotificationIndexFiltered result = _nApiRepo.GetFilteredAndSortedNotifications(model); return(result); }