コード例 #1
0
        public JsonResult ModifyModule(ContentModule entity)
        {
            var result = new JsonResult()
            {
                Data = new
                {
                    success = false,
                    message = "There as an error processing your request"
                }
            };

            if (String.IsNullOrEmpty(entity.ModuleName))
            {
                return(result);
            }

            var editedContent = Context.ContentModules.FirstOrDefault(x => x.ContentModuleId == entity.ContentModuleId);

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

            if (editedContent.ParentContentModuleId.HasValue)
            {
                editedContent = Context.ContentModules.FirstOrDefault(x => x.ContentModuleId == editedContent.ParentContentModuleId.Value);
                if (editedContent == null)
                {
                    return(result);
                }
            }

            SaveDraft(editedContent, editedContent.CreateDate);

            editedContent.DraftAuthorName = UserUtils.CurrentMembershipUsername();
            editedContent.CreateDate      = DateTime.UtcNow;
            LoadContentFromUploadedModel(entity, editedContent);
            editedContent.IsActive = true;

            var success = Context.SaveChanges();

            if (success > 0)
            {
                CachedObjects.GetCacheContentModules(true);

                BookmarkUtil.UpdateTitle("/admin/modules/" + editedContent.ContentModuleId + "/", editedContent.ModuleName);
                result.Data = new
                {
                    success = true,
                    message = "Content saved successfully.",
                    date    = SystemTime.CurrentLocalTime.ToString("dd/MM/yyy @ h:mm tt")
                };
            }

            return(result);
        }
コード例 #2
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);
        }
コード例 #3
0
        public JsonResult ModifyBlog(EditBlogModel entity)
        {
            if (String.IsNullOrEmpty(entity.Title))
            {
                return(NoBlogTitleError);
            }

            var blogEntity = Context.Blogs.FirstOrDefault(x => x.BlogId == entity.BlogId);

            if (blogEntity == null)
            {
                return(JsonErrorResult);
            }

            Mapper.Map(entity, blogEntity);
            // Database Nav property mappings
            blogEntity.Category   = Utils.GetCategoryOrUncategorized(entity.Category);
            blogEntity.BlogAuthor = Context.BlogUsers.First(usr => usr.UserId == entity.AuthorId);

            if (blogEntity.Tags == null)
            {
                blogEntity.Tags = new List <BlogTag>();
            }
            else
            {
                blogEntity.Tags.Clear();
            }

            if (!String.IsNullOrEmpty(entity.Tags))
            {
                foreach (var tag in entity.Tags.Split(','))
                {
                    blogEntity.Tags.Add(Utils.GetOrCreateTag(tag));
                }
            }

            var success = Context.SaveChanges();

            CachedObjects.GetCacheContentPages(true);
            BookmarkUtil.UpdateTitle("/admin/pages/editblog/" + blogEntity.BlogId + "/", entity.Title);

            return(success > 0
                ? BlogSaveSuccess(entity)
                : JsonErrorResult);
        }
コード例 #4
0
        public JsonResult SaveSchema(int id, string data, string name)
        {
            var result = new JsonResult();

            var schema = Context.Schemas.FirstOrDefault(x => x.SchemaId == id);

            if (schema != null)
            {
                schema.JSONData    = data;
                schema.DisplayName = name;
            }

            Context.SaveChanges();
            BookmarkUtil.UpdateTitle("/admin/schemas/editschema/" + id + "/", name);

            result.Data = new { };

            return(result);
        }
コード例 #5
0
        public JsonResult ModifyContent(ContentPage entity, bool isBasic)
        {
            var result = new JsonResult();

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

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

            ContentPage editedContent =
                Context.ContentPages.FirstOrDefault(x => x.ContentPageId == entity.ContentPageId);

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

            SaveDraft(editedContent, editedContent.PublishDate);
            BookmarkUtil.UpdateTitle("/admin/pages/editcontent/" + editedContent.ContentPageId + "/", entity.Title);

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

            Context.SaveChanges();

            CachedObjects.GetCacheContentPages(true);

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

            return(result);
        }
コード例 #6
0
        public JsonResult ModifyModule(ContentModule entity)
        {
            var result = new JsonResult()
            {
                Data = new
                {
                    success = false,
                    message = "There as an error processing your request"
                }
            };

            var success = 0;

            if (String.IsNullOrEmpty(entity.ModuleName))
            {
                return(result);
            }

            var editedContent = Context.ContentModules.FirstOrDefault(x => x.ContentModuleId == entity.ContentModuleId);

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

            if (editedContent.ParentContentModuleId.HasValue)
            {
                editedContent = Context.ContentModules.FirstOrDefault(x => x.ContentModuleId == editedContent.ParentContentModuleId.Value);
                if (editedContent == null)
                {
                    return(result);
                }
            }

            SaveDraft(editedContent, editedContent.CreateDate);

            editedContent.DraftAuthorName   = UserUtils.CurrentMembershipUsername();
            editedContent.CreateDate        = DateTime.UtcNow;
            editedContent.ModuleName        = ContentUtils.ScrubInput(entity.ModuleName);
            editedContent.HTMLContent       = entity.HTMLContent;
            editedContent.HTMLUnparsed      = entity.HTMLUnparsed;
            editedContent.JSContent         = entity.JSContent;
            editedContent.CSSContent        = entity.CSSContent;
            editedContent.SchemaId          = entity.SchemaId;
            editedContent.SchemaEntryValues = entity.SchemaEntryValues;
            editedContent.IsActive          = true;

            success = Context.SaveChanges();

            if (success > 0)
            {
                BookmarkUtil.UpdateTitle("/admin/modules/" + editedContent.ContentModuleId + "/", editedContent.ModuleName);
                result.Data = new
                {
                    success = true,
                    message = "Content saved successfully.",
                    date    = editedContent.CreateDate.Value.ToString("dd/MM/yyy @ h:mm tt")
                };
            }

            return(result);
        }
コード例 #7
0
        public JsonResult ModifyBlog(EditBlogModel entity)
        {
            if (String.IsNullOrEmpty(entity.Title))
            {
                return(new JsonResult
                {
                    Data = new
                    {
                        success = false,
                        message = "Your post must have a title"
                    }
                });
            }

            var editedBlog = Context.Blogs.FirstOrDefault(x => x.BlogId == entity.BlogId);

            if (editedBlog == null)
            {
                return(JsonErrorResult);
            }

            // Straight copies from the model
            editedBlog.AuthorId    = entity.AuthorId;
            editedBlog.HtmlContent = entity.HtmlContent;
            editedBlog.IsActive    = entity.IsActive;
            editedBlog.IsFeatured  = entity.IsFeatured;
            editedBlog.ShortDesc   = entity.ShortDesc;
            editedBlog.Date        = entity.Date;
            // Meta
            editedBlog.Canonical       = entity.Canonical;
            editedBlog.OGImage         = entity.OGImage;
            editedBlog.OGTitle         = entity.OGTitle;
            editedBlog.OGType          = entity.OGType;
            editedBlog.OGUrl           = entity.OGUrl;
            editedBlog.MetaDescription = entity.MetaDescription;

            // Cleaned inpuit
            editedBlog.Title     = ContentUtils.ScrubInput(entity.Title);
            editedBlog.ImageUrl  = ContentUtils.ScrubInput(entity.ImageUrl);
            editedBlog.PermaLink = ContentUtils.GetFormattedUrl(entity.PermaLink);

            // Database Nav property mappings
            editedBlog.Category   = utils.GetCategoryOrUncategorized(entity.Category);
            editedBlog.BlogAuthor = Context.BlogUsers.First(usr => usr.UserId == entity.AuthorId);

            if (editedBlog.Tags == null)
            {
                editedBlog.Tags = new List <BlogTag>();
            }

            if (!String.IsNullOrEmpty(entity.Tags))
            {
                foreach (var tag in entity.Tags.Split(','))
                {
                    editedBlog.Tags.Add(utils.GetOrCreateTag(tag));
                }
            }

            var success = Context.SaveChanges();

            CachedObjects.GetCacheContentPages(true);
            BookmarkUtil.UpdateTitle("/admin/pages/editblog/" + editedBlog.BlogId + "/", entity.Title);

            if (success > 0)
            {
                return(new JsonResult
                {
                    Data = new
                    {
                        success = true,
                        message = "Blog saved successfully.",
                        id = entity.BlogId
                    }
                });
            }

            return(JsonErrorResult);
        }