public List <SiteNav> PerformDataPagingQueryableContent(Guid siteID, bool bActiveOnly, int pageSize, int pageNumber, string sortField, string sortDir, IQueryable <vw_carrot_Content> QueryInput) { IEnumerable <SiteNav> lstContent = new List <SiteNav>(); int startRec = pageNumber * pageSize; if (pageSize < 0 || pageSize > 200) { pageSize = 25; } if (pageNumber < 0 || pageNumber > 10000) { pageNumber = 0; } if (String.IsNullOrEmpty(sortField)) { sortField = "CreateDate"; } if (String.IsNullOrEmpty(sortDir)) { sortDir = "DESC"; } bool IsContentProp = false; sortDir = sortDir.ToUpper(); sortField = (from p in ReflectionUtilities.GetPropertyStrings(typeof(vw_carrot_Content)) where p.ToLower().Trim() == sortField.ToLower().Trim() select p).FirstOrDefault(); if (!String.IsNullOrEmpty(sortField)) { IsContentProp = ReflectionUtilities.DoesPropertyExist(typeof(vw_carrot_Content), sortField); } if (IsContentProp) { QueryInput = ReflectionUtilities.SortByParm <vw_carrot_Content>(QueryInput, sortField, sortDir); } else { QueryInput = (from c in QueryInput orderby c.CreateDate descending where c.SiteID == siteID && c.IsLatestVersion == true && (c.PageActive == bActiveOnly || bActiveOnly == false) select c).AsQueryable(); } lstContent = (from q in QueryInput select new SiteNav(q)).Skip(startRec).Take(pageSize); return(lstContent.ToList()); }
public static List <EditHistory> GetHistoryList(string orderBy, int pageNumber, int pageSize, Guid siteID, bool showLatestOnly, DateTime?editDate, Guid?editUserID) { SortParm srt = new SortParm(orderBy); if (String.IsNullOrEmpty(srt.SortField)) { srt.SortField = "EditDate"; } if (String.IsNullOrEmpty(srt.SortDirection)) { srt.SortDirection = "DESC"; } Guid userID = Guid.Empty; if (editUserID.HasValue) { userID = editUserID.Value; } DateTime dateStart = DateTime.UtcNow.Date.AddDays(-2); DateTime dateEnd = DateTime.UtcNow.Date.AddDays(1); if (editDate.HasValue) { dateStart = editDate.Value.Date.AddDays(-8); dateEnd = editDate.Value.Date.AddDays(1); } int startRec = pageNumber * pageSize; if (pageSize < 0 || pageSize > 200) { pageSize = 25; } if (pageNumber < 0 || pageNumber > 10000) { pageNumber = 0; } bool IsContentProp = false; srt.SortField = (from p in ReflectionUtilities.GetPropertyStrings(typeof(vw_carrot_EditHistory)) where p.ToLowerInvariant().Trim() == srt.SortField.ToLowerInvariant().Trim() select p).FirstOrDefault(); if (!String.IsNullOrEmpty(srt.SortField)) { IsContentProp = ReflectionUtilities.DoesPropertyExist(typeof(vw_carrot_EditHistory), srt.SortField); } using (CarrotCMSDataContext _db = CarrotCMSDataContext.Create()) { List <EditHistory> _history = null; IQueryable <vw_carrot_EditHistory> QueryInput = (from h in _db.vw_carrot_EditHistories where h.SiteID == siteID && (!showLatestOnly || h.IsLatestVersion == true) && (!editDate.HasValue || (h.EditDate.Date >= dateStart.Date && h.EditDate.Date <= dateEnd.Date)) && (!editUserID.HasValue || h.EditUserId == userID) select h); if (IsContentProp) { QueryInput = ReflectionUtilities.SortByParm <vw_carrot_EditHistory>(QueryInput, srt.SortField, srt.SortDirection); } else { QueryInput = (from c in QueryInput orderby c.EditDate descending where c.SiteID == siteID select c).AsQueryable(); } _history = (from h in QueryInput.Skip(startRec).Take(pageSize) select new EditHistory(h)).ToList(); return(_history); } }