Esempio n. 1
0
        public ActionResult PostAddPopup(int categoryId)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageCategories))
            {
                return(AccessDeniedView());
            }

            var model = new CategoryModel.AddCategoryPostModel();

            //categories
            model.AvailableCategories.Add(new SelectListItem
            {
                Text  = _localizationService.GetResource("Admin.Common.All"),
                Value = "0"
            });
            var categories = _categoryService.GetAllCategories(showHidden: true);

            foreach (var c in categories)
            {
                model.AvailableCategories.Add(new SelectListItem
                {
                    Text  = c.GetFormattedBreadCrumb(categories),
                    Value = c.Id.ToString()
                });
            }


            return(View(model));
        }
Esempio n. 2
0
        public ActionResult PostAddPopupList(DataSourceRequest command, CategoryModel.AddCategoryPostModel model)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageCategories))
            {
                return(AccessDeniedView());
            }

            var gridModel = new DataSourceResult();
            var posts     = _postService.SearchPosts(
                categoryIds: new List <int> {
                model.SearchCategoryId
            },
                keywords: model.SearchPostName,
                pageIndex: command.Page - 1,
                pageSize: command.PageSize,
                showHidden: true
                );

            gridModel.Data  = posts.Select(x => x.ToModel());
            gridModel.Total = posts.TotalCount;

            return(Json(gridModel));
        }
Esempio n. 3
0
        public ActionResult PostAddPopup(string btnId, string formId, CategoryModel.AddCategoryPostModel model)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageCategories))
            {
                return(AccessDeniedView());
            }

            if (model.SelectedPostIds != null)
            {
                foreach (var id in model.SelectedPostIds)
                {
                    var product = _postService.GetPostById(id);
                    if (product != null)
                    {
                        var existingPostCategories = _categoryService.GetPostCategoriesByCategoryId(model.CategoryId,
                                                                                                    showHidden: true);
                        if (existingPostCategories.FindPostCategory(id, model.CategoryId) == null)
                        {
                            _categoryService.InsertPostCategory(
                                new PostCategory
                            {
                                CategoryId     = model.CategoryId,
                                PostId         = id,
                                IsFeaturedPost = false,
                                DisplayOrder   = 1
                            });
                        }
                    }
                }
            }

            ViewBag.RefreshPage = true;
            ViewBag.btnId       = btnId;
            ViewBag.formId      = formId;
            return(View(model));
        }