public ActionResult Highlights(int page = 1) { if (page < 1) { return(RedirectToActionPermanent("Highlights", new { page = 1 })); } IQueryable <Content> contents = _contentService.GetAllContentsByTypes(new[] { ContentType.Events, ContentType.Calendars }) .Where(c => c.IsPublished); contents = contents.OrderByDescending(c => c.Comments.Count).ThenByDescending(c => c.PublishDateTicks); IPagination <Content> results; if (ControllerContext.IsChildAction) { results = new LazyPagination <Content>(contents, page, Constants.RecordPerPartial); } else { results = new LazyPagination <Content>(contents, page, Constants.RecordPerPage); } if (!results.Any() && page != 1) { return(RedirectToActionPermanent("Highlights", new { page = 1 })); } return(ViewOrPartialView(results)); }
public ActionResult Archive(int page = 1) { if (page < 1) { return(RedirectToActionPermanent("Archive", new { page = 1 })); } IQueryable <Content> news = _contentService.GetAllContentsByTypes(new[] { ContentType.News }).Where(c => c.IsPublished); news = news.OrderByDescending(c => c.IsHot).ThenBy(c => c.DisplayOrder).ThenByDescending( c => c.PublishDateTicks); IPagination <Content> results; if (ControllerContext.IsChildAction) { results = new LazyPagination <Content>(news, page, Constants.RecordPerPartial); } else { results = new LazyPagination <Content>(news, page, Constants.RecordPerPage); } if (!results.Any() && page != 1) { return(RedirectToActionPermanent("Archive", new { page = 1 })); } return(ViewOrPartialView(results)); }
public ActionResult Archive(int page = 1) { if (page < 1) { return(RedirectToActionPermanent("Archive", new { page = 1 })); } IQueryable <Poll> polls = _pollService.GetAllPolls().Where(p => p.IsActive); polls = polls.OrderBy(c => c.CreateDateTicks); IPagination <Poll> results; if (ControllerContext.IsChildAction) { results = new LazyPagination <Poll>(polls, page, Constants.RecordPerPartial); } else { results = new LazyPagination <Poll>(polls, page, Constants.RecordPerPage); } if (!results.Any() && page != 1) { return(RedirectToActionPermanent("Archive", new { page = 1 })); } return(ViewOrPartialView(results)); }
public ActionResult List(string logLevel = null, int page = 1) { IPagination <Log> results; if (logLevel == null) { if (page < 1) { return(RedirectToActionPermanent("List", new { page = 1 })); } IQueryable <Log> query = _logService.GetAllLogs().OrderByDescending(l => l.LogDate); results = new LazyPagination <Log>(query, page, Constants.RecordPerPage); if (!results.Any() && page != 1) { return(RedirectToActionPermanent("List", new { page = 1 })); } } else { LogLevel level; if (!ExtractLogLevel(logLevel, out level)) { return(NotFoundView()); } if (page < 1) { return(RedirectToActionPermanent("List", new { page = 1, logLevel = level })); } IQueryable <Log> query = _logService.GetAllLogsByLevel(new[] { level }).OrderByDescending(l => l.LogDate); results = new LazyPagination <Log>(query, page, Constants.RecordPerPage); if (!results.Any() && page != 1) { return(RedirectToActionPermanent("List", new { page = 1, logLevel = level })); } ViewBag.LogLevel = level; } return(ViewOrPartialView(results)); }
public ActionResult List(int page = 1) { if (page < 1) { return(RedirectToActionPermanent("List", new { page = 1 })); } var results = new LazyPagination <Role>(_roleService.GetAllRoles().OrderBy(c => c.Id), page, Constants.RecordPerPage); if (!results.Any() && page != 1) { return(RedirectToActionPermanent("List", new { page = 1 })); } return(ViewOrPartialView(results)); }
private string GetSqlGrid(LazyPagination pagger) { var sql = _sql ?? _gridModel.GridSql; sql = _filter.AddCondition(sql); var orderColumns = _gridModel.Column.First(x => string.Equals(x.SystemName, _gridOptions.SortOptions.Column, StringComparison.OrdinalIgnoreCase)); string orderColumn = orderColumns.OrderByName ?? orderColumns.SystemName; var orderBy = new OrderByBuilder(orderColumn, _gridOptions.SortOptions.Direction).QueryResult; sql += Environment.NewLine + orderBy; sql += Environment.NewLine + pagger.GetOffestRow(); return(sql); }
public ActionResult List(int?ownerId, int page = 1) { if (page < 1 || (ownerId.HasValue && ownerId < 1)) { if (ownerId > 0) { return(RedirectToActionPermanent("List", new { page = 1, ownerId })); } return(RedirectToActionPermanent("List", new { page = 1 })); } IQueryable <Comment> query; if (ownerId.HasValue) { query = _commentService.GetAllCommentsByOwnerId(ownerId.Value).OrderBy(c => c.Id); } else { query = _commentService.GetAllComments().OrderBy(c => c.Id); } ExcludeNotRealatedRecords(ref query); var results = new LazyPagination <Comment>(query, page, Constants.RecordPerPage); if (!results.Any() && page != 1) { return(RedirectToActionPermanent("List", new { page = 1 })); } ViewBag.OwnerId = ownerId; return(ViewOrPartialView(results)); }
public ActionResult List(int?parentId = null, int page = 1, int recordPerPage = Constants.RecordPerPage) { IPagination <File> results; if (parentId == null) { if (page < 1) { return(RedirectToActionPermanent("List", new { page = 1 })); } IQueryable <File> query = _fileService.GetAllFiles(); ExcludeNotRealatedRecords(ref query); query = query.OrderBy(c => c.Id).AsQueryable(); results = new LazyPagination <File>(query, page, recordPerPage); if (!results.Any() && page != 1) { return(RedirectToActionPermanent("List", new { page = 1 })); } } else { File parent = _fileService.GetFileById(parentId.Value); if (parent == null) { return(NotFoundView()); } if (page < 1) { return(RedirectToActionPermanent("List", new { page = 1, parentId })); } IQueryable <File> query = _fileService.GetAllFilesByParentId(parent.Id); ExcludeNotRealatedRecords(ref query); query = query.OrderBy(c => c.Id).AsQueryable(); results = new LazyPagination <File>(query, page, recordPerPage); if (!results.Any() && page != 1) { return(RedirectToActionPermanent("List", new { page = 1, parentId })); } ViewBag.Parent = parent; } ViewBag.RecordPerPage = recordPerPage; return(ViewOrPartialView(results)); }
public ActionResult List(string contentType = null, int page = 1, int recordPerPage = Constants.RecordPerPage) { IPagination <Content> results; if (contentType == null) { if (page < 1) { return(RedirectToActionPermanent("List", new { page = 1 })); } IQueryable <Content> query = _contentService.GetAllContents(); ExcludeNotRealatedRecords(ref query); query = query.OrderBy(c => c.Id).AsQueryable(); results = new LazyPagination <Content>(query, page, recordPerPage); if (!results.Any() && page != 1) { return(RedirectToActionPermanent("List", new { page = 1 })); } } else { ContentType type; if (!ExtractContentType(contentType, out type)) { return(NotFoundView()); } if (page < 1) { return(RedirectToActionPermanent("List", new { page = 1, contentType = type })); } IQueryable <Content> query = _contentService.GetAllContentsByTypes(new[] { type }); ExcludeNotRealatedRecords(ref query); query = query.OrderBy(c => c.Id).AsQueryable(); results = new LazyPagination <Content>(query, page, recordPerPage); if (!results.Any() && page != 1) { return(RedirectToActionPermanent("List", new { page = 1, contentType = type })); } ViewBag.ContentType = type; } ViewBag.RecordPerPage = recordPerPage; return(ViewOrPartialView(results)); }