Ejemplo n.º 1
0
        public ActionResult PostCategoryInsert(PostModel.PostCategoryModel model)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManagePosts))
            {
                return(AccessDeniedView());
            }

            var postId     = model.PostId;
            var categoryId = model.CategoryId;


            var existingPostCategories = _categoryService.GetPostCategoriesByCategoryId(categoryId, showHidden: true);

            if (existingPostCategories.FindPostCategory(postId, categoryId) == null)
            {
                var postCategory = new PostCategory
                {
                    PostId       = postId,
                    CategoryId   = categoryId,
                    DisplayOrder = model.DisplayOrder
                };

                _categoryService.InsertPostCategory(postCategory);
            }

            return(new NullJsonResult());
        }
Ejemplo n.º 2
0
        public ActionResult PostCategoryUpdate(PostModel.PostCategoryModel model)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManagePosts))
            {
                return(AccessDeniedView());
            }

            var postCategory = _categoryService.GetPostCategoryById(model.Id);

            if (postCategory == null)
            {
                throw new ArgumentException("No post category mapping found with the specified id");
            }


            postCategory.CategoryId   = model.CategoryId;
            postCategory.DisplayOrder = model.DisplayOrder;

            _categoryService.UpdatePostCategory(postCategory);

            return(new NullJsonResult());
        }