示例#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 JsonResult ChangeDraftStatus(ContentPageComplete page)
        {
            var result = new JsonResult();

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

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

            // Return last publish date if we just changed to publish
            if (Convert.ToBoolean(page.Details.IsActive))
            {
                if (editedContent != null)
                {
                    editedContent.PublishDate = DateTime.UtcNow;
                }

                result.Data = new { publishDate = Convert.ToDateTime(DateTime.UtcNow).ToString("MM/dd/yyyy @ hh:mm") };
            }

            Context.SaveChanges();

            return(result);
        }
示例#3
0
        public JsonResult SaveDraft(ContentPageComplete page, DateTime?publishDate)
        {
            var id = SaveDraftInDb(page, publishDate);

            return(new JsonResult {
                Data = new { id }
            });
        }
示例#4
0
        private int SaveDraftInDb(ContentPageComplete page, DateTime?publishDate)
        {
            var draft = new ContentPage();

            SetContentPageData(draft, page.Details, true, false, publishDate);

            Context.ContentPages.Add(draft);
            Context.SaveChanges();
            return(draft.ContentPageId);
        }
示例#5
0
        public JsonResult ModifyContent(ContentPageComplete page, bool isBasic)
        {
            var result = new JsonResult();

            if (page.Details == null || String.IsNullOrEmpty(page.Details.Title))
            {
                return(result);
            }

            if (String.IsNullOrEmpty(page.Details.Title))
            {
                return(result);
            }

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

            if (editedContent == null)
            {
                return(result);
            }

            var contentUtility = new ContentUtils();

            if (contentUtility.CheckPermalink(page.Details.Permalink, page.Details.ContentPageId,
                                              page.Details.ParentNavigationItemId))
            {
                // permalink exists already under this parent page id
                result.Data = new
                {
                    permalinkExists = true
                };
                return(result);
            }

            SaveDraftInDb(page, editedContent.PublishDate);
            BookmarkUtil.UpdateTitle("/admin/pages/editcontent/" + editedContent.ContentPageId + "/", page.Details.Title);

            SetContentPageData(editedContent, page.Details, false, isBasic, null);
            UpdatePageExtenstion(page);
            editedContent.IsActive = true; // Saving / Publishing content sets this to true.
            editedContent.NoIndex  = page.Details.NoIndex;
            editedContent.NoFollow = page.Details.NoFollow;

            Context.SaveChanges();

            CachedObjects.GetCacheContentPages(true);

            result.Data = new { publishDate = SystemTime.CurrentLocalTime.ToString("MM/dd/yyyy @ hh:mm") };

            return(result);
        }
示例#6
0
        private void UpdatePageExtenstion(ContentPageComplete page)
        {
            var ext = Context.ContentPageExtensions.FirstOrDefault(x => x.ContentPageId == page.Details.ContentPageId);

            if (ext == null)
            {
                ext = new ContentPageExtension
                {
                    ContentPageId = page.Details.ContentPageId
                };

                Context.ContentPageExtensions.Add(ext);
            }

            Mapper.Map <ContentPageComplete, ContentPageExtension>(page, ext);
            Context.SaveChanges();
        }
 public EditContentViewModel()
 {
     ShowFieldEditor    = false;
     ShowSchemaSelector = false;
     ContentPage        = new ContentPageComplete();
 }