예제 #1
0
        public JsonResult ChangeDraftStatus(ContentPageComplete page)
        {
            var      result      = new JsonResult();
            DateTime?publishDate = null;

            var editedContent = Context.ContentPages.FirstOrDefault(x => x.ContentPageId == page.Details.ContentPageId);

            if (editedContent == null)
            {
                return(result);
            }
            editedContent.IsActive = page.Details.IsActive;

            if (page.Details.IsActive)
            {
                editedContent.PublishDate = DateTime.UtcNow;
            }
            publishDate = editedContent.PublishDate;

            result.Data = new { publishDate = publishDate.HasValue ? TimeUtils.ConvertUTCToLocal(publishDate.Value).ToString("MM/dd/yyyy @ hh:mm") : "" };

            Context.SaveChanges();

            return(result);
        }
예제 #2
0
        public void LoadEvents()
        {
            if (Context.Events.Any())
            {
                EventListing = Context.Events.ToList();
            }

            foreach (var edgeEvent in EventListing)
            {
                if (edgeEvent.StartDate.HasValue)
                {
                    edgeEvent.StartDate = TimeUtils.ConvertUTCToLocal(edgeEvent.StartDate.Value);
                }

                if (edgeEvent.EndDate.HasValue)
                {
                    edgeEvent.EndDate = TimeUtils.ConvertUTCToLocal(edgeEvent.EndDate.Value);
                }
            }
        }
예제 #3
0
        public JsonResult GetRevisionList(int id)
        {
            var result = new JsonResult {
                JsonRequestBehavior = JsonRequestBehavior.AllowGet
            };

            var drafts = Context.ContentPages.Where(x => x.ParentContentPageId == id || x.ContentPageId == id).OrderByDescending(x => x.PublishDate).ToList().Select(rev => new RevisionViewModel
            {
                Date         = TimeUtils.ConvertUTCToLocal(rev.PublishDate),
                ContentId    = rev.ContentPageId,
                AuthorName   = rev.DraftAuthorName,
                WasPublished = rev.WasPublished
            }).ToList();

            var html = ContentUtils.RenderPartialViewToString("/Areas/Admin/Views/Shared/Partials/RevisionsListInnerPartial.cshtml", drafts, ControllerContext, ViewData, TempData);

            result.Data = new { html };

            return(result);
        }