public ActionResult Index(long block_id, long?page, long?content_root) { ViewBag.block_id = block_id; dynamic block = null; using (BlockRepository block_repository = new BlockRepository()) { block = block_repository.GetByID(block_id); ViewBag.blcoks = block_repository.All(CurrentUser.user_domain); } content_root = content_root ?? block.block_content_root; ViewBag.content_root = content_root; page = page ?? 1; long totals; using (ContentRepository content_repository = new ContentRepository()) { string order_by = (string.IsNullOrWhiteSpace(block.block_order_fields) || block.block_allow_sort ? "content_order, content_publish desc" : block.block_order_fields); if (content_root.HasValue) { using (TemplateRepository template_repository = new TemplateRepository()) { dynamic root_item = content_repository.GetByID(content_root.Value); dynamic root_template = template_repository.GetByID(root_item.content_template); if (root_template.template_allow_subpartitions) { ViewBag.template_allow_sort = root_template.template_allow_sort; order_by = (string.IsNullOrWhiteSpace(root_template.template_order_fields) || root_template.template_allow_sort ? "content_order, content_publish desc" : root_template.template_order_fields); } } } ViewBag.items = content_repository.Get(CurrentUser.user_domain, block_id, content_root, order_by, page ?? 1, block.block_allow_sort ? Int64.MaxValue : 50, out totals); } ViewBag.page = page; ViewBag.totals = totals; List <dynamic> nav = content_root != null?ModelUtility.GetNavi(content_root, block.block_content_root, false) : new List <dynamic>(); if (nav.Count > 0 && block.block_content_root == null) { nav.Insert(0, null); } ViewBag.nav = nav; ViewBag.block = block; return(View()); }