public GetContentHistoryResponse Get(GetContentHistoryRequest request) { var results = historyService.GetContentHistory(request.ContentId, new SearchableGridOptions()) .AsQueryable() .OrderBy(history => history.CreatedOn) .Select(history => new { Type = history.GetType(), Model = new HistoryContentModel { Id = history.Id, Version = history.Version, CreatedBy = history.CreatedByUser, CreatedOn = history.CreatedOn, LastModifiedBy = history.ModifiedByUser, LastModifiedOn = history.ModifiedOn, OriginalContentId = history.Original != null ? history.Original.Id : (System.Guid?)null, PublishedOn = history.Status == CoreContentStatus.Published ? history.PublishedOn : null, PublishedByUser = history.Status == CoreContentStatus.Published ? history.PublishedByUser : null, ArchivedOn = history.Status == CoreContentStatus.Archived ? history.CreatedOn : (System.DateTime?)null, ArchivedByUser = history.Status == CoreContentStatus.Archived ? history.CreatedByUser : null, Status = (ContentStatus)((int)history.Status) } }) .ToList(); // Set content types results.ForEach(item => item.Model.ContentType = item.Type.ToContentTypeString()); return new GetContentHistoryResponse { Data = results.Select(item => item.Model).ToList() }; }
/// <summary> /// Gets the list with historical content entities. /// </summary> /// <param name="request">The request.</param> /// <returns> /// Historical content entities /// </returns> /// <exception cref="CmsApiException"></exception> public DataListResponse <Content> GetContentHistory(GetContentHistoryRequest request) { try { return(historyService.GetContentHistory(request.ContentId, new SearchableGridOptions()) .AsQueryable() .ApplyFilters(request) .AddOrder(request) .ToDataListResponse()); } catch (Exception inner) { var message = string.Format("Failed to get history for content id={0}.", request.ContentId); Logger.Error(message, inner); throw new CmsApiException(message, inner); } }
/// <summary> /// Gets the list with historical content entities. /// </summary> /// <param name="request">The request.</param> /// <returns> /// Historical content entities /// </returns> /// <exception cref="CmsApiException"></exception> public DataListResponse<Content> GetContentHistory(GetContentHistoryRequest request) { try { return historyService.GetContentHistory(request.ContentId, new SearchableGridOptions()) .AsQueryable() .ApplyFilters(request) .AddOrder(request) .ToDataListResponse(); } catch (Exception inner) { var message = string.Format("Failed to get history for content id={0}.", request.ContentId); Logger.Error(message, inner); throw new CmsApiException(message, inner); } }
public ActionResult TestApi() { /*PagesApiContext.Events.PageCreated += EventsOnPageCreated; * * PagesApiContext.Events.OnPageCreated(new PageProperties()); * * ApiContext.Events.HostStart += Core_HostStart;*/ var message = string.Empty; DataListResponse <BlogPost> results; using (var api = CmsContext.CreateApiContextOf <BlogsApiContext>()) { using (var papi = CmsContext.CreateApiContextOf <PagesApiContext>()) { var aRequest = new GetContentHistoryRequest(new Guid("AE04E233-4E88-4A9F-87BC-A1CC00F2C173")); var aresults = papi.GetContentHistory(aRequest); if (aresults.Items.Count > 0) { message = string.Format("{0}<br />Total count:{2}, Item titles: {1}", message, string.Join("; ", aresults.Items.Select(t => t.Name)), aresults.TotalCount); } aRequest = new GetContentHistoryRequest(new Guid("AE04E233-4E88-4A9F-87BC-A1CC00F2C173"), a => a.Name.ToLower().Contains("poop"), o => o.Name, orderDescending: true); aresults = papi.GetContentHistory(aRequest); if (aresults.Items.Count > 0) { message = string.Format("{0}<br />Total count:{2}, Item titles: {1}", message, string.Join("; ", aresults.Items.Select(t => t.Name)), aresults.TotalCount); } /*var request = new GetDataRequest<Layout>(3, 2, orderDescending:true, order:t =>t.Name); * results = pagesApi.GetLayouts(request);*/ /*var request = new GetDataRequest<LayoutRegion>(orderDescending: true, order: t => t.Region.RegionIdentifier); * request.AddPaging(2, 2);*/ /*var request = new GetBlogPostsRequest(b => b.ExpirationDate.HasValue, includePrivate: true, includeUnpublished: true, itemsCount: 3); * results = api.GetBlogPosts(request); * * if (results.Items.Count > 0) * { * message = string.Format( * "{0}<br />Total count:{2}, Item titles: {1}", message, string.Join("; ", results.Items.Select(t => t.Title)), results.TotalCount); * } * * request = new GetBlogPostsRequest(order: b => b.Title, orderDescending: true, includePrivate: true, includeUnpublished: true); * request.AddPaging(3, 3); * results = api.GetBlogPosts(request); * * if (results.Items.Count > 0) * { * message = string.Format( * "{0}<br />Total count:{2}, Item titles: {1}", message, string.Join("; ", results.Items.Select(t => t.Title)), results.TotalCount); * } * * request = new GetBlogPostsRequest( * order: b => b.Title, orderDescending: true, itemsCount: 5, startItemNumber: 3, includeUnpublished: true, includePrivate: true); * results = api.GetBlogPosts(request);*/ } } return(Content(message)); }
public ActionResult ContentHistory(GetContentHistoryRequest request) { var model = GetCommand <GetContentHistoryCommand>().ExecuteCommand(request); return(View(model)); }
public ActionResult TestApi() { /*PagesApiContext.Events.PageCreated += EventsOnPageCreated; PagesApiContext.Events.OnPageCreated(new PageProperties()); ApiContext.Events.HostStart += Core_HostStart;*/ var message = string.Empty; DataListResponse<BlogPost> results; using (var api = CmsContext.CreateApiContextOf<BlogsApiContext>()) { using (var papi = CmsContext.CreateApiContextOf<PagesApiContext>()) { var aRequest = new GetContentHistoryRequest(new Guid("AE04E233-4E88-4A9F-87BC-A1CC00F2C173")); var aresults = papi.GetContentHistory(aRequest); if (aresults.Items.Count > 0) { message = string.Format("{0}<br />Total count:{2}, Item titles: {1}", message, string.Join("; ", aresults.Items.Select(t => t.Name)), aresults.TotalCount); } aRequest = new GetContentHistoryRequest(new Guid("AE04E233-4E88-4A9F-87BC-A1CC00F2C173"), a => a.Name.ToLower().Contains("poop"), o => o.Name, orderDescending: true); aresults = papi.GetContentHistory(aRequest); if (aresults.Items.Count > 0) { message = string.Format("{0}<br />Total count:{2}, Item titles: {1}", message, string.Join("; ", aresults.Items.Select(t => t.Name)), aresults.TotalCount); } /*var request = new GetDataRequest<Layout>(3, 2, orderDescending:true, order:t =>t.Name); results = pagesApi.GetLayouts(request);*/ /*var request = new GetDataRequest<LayoutRegion>(orderDescending: true, order: t => t.Region.RegionIdentifier); request.AddPaging(2, 2);*/ /*var request = new GetBlogPostsRequest(b => b.ExpirationDate.HasValue, includePrivate: true, includeUnpublished: true, itemsCount: 3); results = api.GetBlogPosts(request); if (results.Items.Count > 0) { message = string.Format( "{0}<br />Total count:{2}, Item titles: {1}", message, string.Join("; ", results.Items.Select(t => t.Title)), results.TotalCount); } request = new GetBlogPostsRequest(order: b => b.Title, orderDescending: true, includePrivate: true, includeUnpublished: true); request.AddPaging(3, 3); results = api.GetBlogPosts(request); if (results.Items.Count > 0) { message = string.Format( "{0}<br />Total count:{2}, Item titles: {1}", message, string.Join("; ", results.Items.Select(t => t.Title)), results.TotalCount); } request = new GetBlogPostsRequest( order: b => b.Title, orderDescending: true, itemsCount: 5, startItemNumber: 3, includeUnpublished: true, includePrivate: true); results = api.GetBlogPosts(request);*/ } } return Content(message); }