public ActionResult Category(int id, int? page)
        {
            Models.ContentCategory Cat = new CategoryService().GetById(id);
            if (Cat == null) return RedirectToAction("Index", "Http404");

            ViewData.Model = new CategoryViewData() {
                Category = new CategoryService().GetById(id),
                Articles = new ContentService().GetContentByCategoryId(id),
                FeaturedArticles = new ContentService().GetFeaturedArtileByCategoryId(id),
                ArticlesPagedList = new ContentService().All(id).ToPagedList(page.HasValue?page.Value-1:0, DBNLConfigurationManager.WebUI.ArticlePagingItem)

            };
            return View();
        }
 public ActionResult List(int page, int rows, string sidx, string sord, int? ParentId)
 {
     var categories = new CategoryService().List(ParentId);
     bool searchOn = bool.Parse(Request.Form["_search"]);
     string searchExp = "";
     
     var model = from entity in categories.OrderBy(sidx + " " + sord)
                 select new
                 {
                     Id = entity.ID,
                     Name = entity.CategoryName,
                     ParentCateId = entity.ParentCategoryId,
                     IsFeatured = entity.IsFeatured,
                     ShowOnHP = entity.ShowOnHP,
                     Articles = entity.CountArticles(true),
                     Url = Url.Action(Actions.Category.ToString(), SiteModules.Article.ToString(), new {id = entity.ID, Area=""})
                 };
     return Json(model.ToJqGridData(page, rows, null, "", new[] { "Name", "ParentCateId", "IsFeatured", "ShowOnHP" }), JsonRequestBehavior.AllowGet);
 }
 public ActionResult CreateIn(int id)
 {
     ViewData["Category"] = new CategoryService().GetById(id);
     return View(new Models.Content() {CategoryId =  id});
 } 
        public ActionResult CreateIn (Models.Content content, FormCollection collection)
        {
            try
            {
                HttpPostedFileBase picture = (HttpPostedFileBase)Request.Files["Picture"];
                content.UniqueKey = content.Title.ToUrlKey();
                content.Status = EntityStatuses.Actived.ToString();


                if (!ModelState.IsValid)
                {
                    ViewData["Category"] = new CategoryService().GetById(content.CategoryId);
                    return View(content);
                }
                //content.Content1 = StringTemplateHelper.ReplaceVideoTag(content.Content1);
                new ContentService().Create(content, picture);

                return RedirectToAction("ViewCat", "Categories", new { id = content.CategoryId });
            }
            catch
            {
                ViewData["Category"] = new CategoryService().GetById(content.CategoryId);
                return View(content);
            }
        }
        public ActionResult TreeNode(int? Node, FormCollection collection)
        {
            IEnumerable<ContentCategory> categories =null;
            if (Node == null)
            {
                categories = new CategoryService().GetItems(new Nullable<int>());
            }
            else
            {
                categories = new CategoryService().GetItems(Node.Value);
            }
            var query = from p in categories
                        select new {
                            text=p.CategoryName,
                            hasChildren = p.ContentCategories.Count>0,
                            id=p.ID.ToString(),
                            classes ="Clickable"
                        };

            return Json(query);
        }
 public ActionResult ViewCat(int id)
 {
     var item = new CategoryService().GetItem(id);
     return View(item);
 }
 public ActionResult Edit(int id)
 {var item = new CategoryService().GetItem(id);
     ViewData["Categories"] = CustomSelectList.CreateListCategories(false);
     ViewData["Status"] = CustomSelectList.CreateEntityStatus().SetSelectedValue(item.Status);
     
     return View(item);
 }
        public ActionResult FullList(int page, int rows, string sidx, string sord)
        {
            var categories = new CategoryService().List();
            bool searchOn = bool.Parse(Request.Form["_search"]);
            string searchExp = "";

            var model = from entity in categories.OrderBy(sidx + " " + sord)
                        select new
                        {
                            Id = entity.ID,
                            Name = entity.CategoryName,
                            Permission="category_" + entity.ID.ToString()
                        };
            return Json(model.ToJqGridData(page, rows, null, "", new[] { "Name", "ParentCateId", "IsFeatured", "ShowOnHP" }), JsonRequestBehavior.AllowGet);
        }
        public ActionResult ViewCategoryByMonth(string category, int? page,  int month, int year)
        {
            Models.ContentCategory Cat = new CategoryService().GetByKey(category);

            if (Cat == null) return RedirectToAction("Index", "Http404");

            DateTime filterDate = DateTime.Now;
            try
            {
                filterDate = new DateTime(year, month, 1);
            }
            catch (Exception ex)
            {
                return RedirectToAction("Index", "Http404");
            }

            var data = new CategoryViewData()
            {
                FilterDate = filterDate,
                Category = Cat,
                Articles = new ContentService().GetContentByCategoryId(Cat.ID),
                FeaturedArticles = new ContentService().GetFeaturedArtileByCategoryId(Cat.ID),
                ArticlesPagedList = new ContentService().All(Cat.ID)
                                                    .Where(p => p.UpdatedDate.Year == year)
                                                    .Where(p => p.UpdatedDate.Month == month)

                                                    .ToPagedList(page.HasValue ? page.Value - 1 : 0, DBNLConfigurationManager.WebUI.ArticlePagingItem)

            };
            if (page.HasValue && data.ArticlesPagedList.PageCount > 0 && page.Value > data.ArticlesPagedList.PageCount)
            {
                return RedirectToAction("ViewCategoryByMonth", new { category = category, month = month, year = year });
            }
            return View("~/Views/Article/CategoryByMonth.aspx", data);
        }
Exemplo n.º 10
0
        public ActionResult ViewCategory(string category, int? page)
        {
            int id = 1;
            //return RedirectToAction("Category", new { id = 1, page = page });
            Models.ContentCategory Cat = new CategoryService().GetByKey(category);

            if (Cat == null) return RedirectToAction("Index", "Http404");
            ViewData.Model = new CategoryViewData()
            {
                Category = Cat,
                Articles = new ContentService().GetContentByCategoryId(Cat.ID),
                FeaturedArticles = new ContentService().GetFeaturedArtileByCategoryId(Cat.ID),
                ArticlesPagedList = new ContentService().All(Cat.ID).ToPagedList(page.HasValue ? page.Value - 1 : 0, DBNLConfigurationManager.WebUI.ArticlePagingItem)

            };
            return View("~/Views/Article/Category.aspx");
        }
Exemplo n.º 11
0
        public static IEnumerable<ContentCategory> GetCategoriesShowOnHPEx()
        {
            CategoryService service = new CategoryService();

            return service.GetCategoriesShowOnHP();
        }