예제 #1
0
        public async Task <ActionResult> load()
        {
            var json   = new StreamReader(Request.Body).ReadToEnd();
            var data   = JsonConvert.DeserializeObject <CategoryEntity>(json);
            var _posts = await CategoryBLL.LoadItems(_context, data);

            foreach (var item in _posts)
            {
                if (item.picturename.StartsWith("http"))
                {
                    item.img_url = item.picturename;
                }
                else
                {
                    item.img_url = Config.GetUrl("contents/category/" + item.picturename);
                }
            }
            var _records = 0;

            if (data.id == 0)
            {
                _records = await CategoryBLL.Count(_context, data);
            }

            return(Ok(new { posts = _posts, records = _records }));
        }
        // GET: videos/categories
        public async Task <IActionResult> categories(int?pagenumber)
        {
            if (pagenumber == null)
            {
                pagenumber = 1;
            }

            /* ***************************************/
            // Process Page Meta & BreaCrumb
            /* ***************************************/
            var _meta = PageMeta.returnPageMeta(new PageQuery()
            {
                controller = ControllerContext.ActionDescriptor.ControllerName,
                index      = ControllerContext.ActionDescriptor.ActionName,
                pagenumber = (int)pagenumber,
            });

            /* List Initialization */
            var ListEntity = new CategoryListViewModel_v2()
            {
                isListStatus = true,
                isListNav    = false,
                QueryOptions = new CategoryEntity()
                {
                    type       = (int)CategoryBLL.Types.Videos,
                    pagenumber = (int)pagenumber,
                    ispublic   = true,
                    term       = "",
                    iscache    = true,
                    pagesize   = 30,
                    order      = "title asc",
                },
                ListObject = new ListItems()
                {
                    ListType = ListType.Grid,
                    ColWidth = "col-md-6 col-sm-12",
                },
                Path              = "videos/", // category url path
                DefaultUrl        = Config.GetUrl("videos/categories"),
                PaginationUrl     = Config.GetUrl("videos/categories/[p]"),
                NoRecordFoundText = SiteConfig.generalLocalizer["_no_records"].Value,
                HeadingTitle      = _meta.title,
                BreadItems        = _meta.BreadItems
            };

            ListEntity.TotalRecords = await CategoryBLL.Count(_context, ListEntity.QueryOptions);

            if (ListEntity.TotalRecords > 0)
            {
                ListEntity.DataList = await CategoryBLL.LoadItems(_context, ListEntity.QueryOptions);
            }

            /**********************************************/
            // Page Meta Setup
            /**********************************************/
            ViewBag.title       = _meta.title;
            ViewBag.description = _meta.description;

            return(View(ListEntity));
        }