Exemplo n.º 1
0
        public ActionResult Post_category_host(int?parent_id)
        {
            ///// Lấy danh sách collection mới nhất
            CatalogModels cateModels  = new CatalogModels();
            var           lstCategory = cateModels.GetbyParentID(0, CommonGlobal.CateService, LanguageModels.ActiveLanguage().LangCultureName, int.Parse(Util.GetConfigValue("NumberListCategory", "0")));

            return(this.PartialView("../control/post_category_host", lstCategory));
        }
Exemplo n.º 2
0
        public ActionResult Post_list_all(string lang, string cate_type, int?cate_id, string link_text, string search, string tag, string param, int?page, int?page_size, string order, string style_list_show)
        {
            CatalogModels cateModels   = new CatalogModels();
            WebInfoModels web_infor    = new Models.WebInfoModels();
            int           total_record = 0;
            PostModels    postModels   = new PostModels();
            C_Catalog     cate         = null;

            ////request query string param
            page = Request.QueryString["page"] != null?Convert.ToInt16(Request.QueryString["page"].ToString()) : 1;

            if (cate_id == null)
            {
                cate_id = RouteData.Values["id"] != null?Convert.ToInt16(RouteData.Values["id"].ToString()) : 0;
            }

            if (string.IsNullOrEmpty(link_text))
            {
                link_text = RouteData.Values["Link"] != null ? RouteData.Values["Link"].ToString() : string.Empty;
            }

            if (cate_id > 0)
            {
                cate = cateModels.GetbyID((int)cate_id);
            }

            ////get order for product list
            string order_by   = string.Empty;
            string order_type = string.Empty;

            if (string.IsNullOrEmpty(order))
            {
                order_by   = "DateModified";
                order_type = "desc";
                order      = order_by + ";" + order_type;
            }
            else
            {
                if (order.Contains(';'))
                {
                    order_by   = order.Split(';')[0];
                    order_type = order.Split(';')[1];
                }
                else
                {
                    order_by   = "DateModified";
                    order_type = "desc";
                    order      = order_by + ";" + order_type;
                }
            }

            postModels.ClearCache(lang + cate_type + (cate_id ?? 0) + search + tag + param + page + page_size + order_by + order_type);

            List <SelectListItem> orderDrop = new List <SelectListItem>();

            orderDrop.AddRange(new SelectListItem[]
            {
                new SelectListItem {
                    Selected = order == "DateModified;desc" ? true : false, Text = App_GlobalResources.Lang.strOrderDateDesc, Value = "DateModified;desc"
                },
                new SelectListItem {
                    Selected = order == "DateModified;asc" ? true : false, Text = App_GlobalResources.Lang.strOrderDateAsc, Value = "DateModified;asc"
                }
            });

            List <C_Catalog> lst_parent     = new List <C_Catalog>();
            List <C_Catalog> lst_parent_all = new List <C_Catalog>();

            if (cate == null || (cate.CategoryName != App_GlobalResources.Lang.mnuRecruitment && cate.CategoryName != App_GlobalResources.Lang.mnuBeautyTips))
            {
                lst_parent = cateModels.GetbyParentID(0, cate_type, lang).Where(p => p.CategoryName != App_GlobalResources.Lang.mnuRecruitment && p.CategoryName != App_GlobalResources.Lang.mnuBeautyTips).ToList();

                foreach (var it in lst_parent)
                {
                    lst_parent_all.Add(it);
                    var lst_child = cateModels.GetbyParentID(it.CatalogID, cate_type, lang).Where(p => p.Show == true).ToList();
                    foreach (var child in lst_child)
                    {
                        lst_parent_all.Add(child);
                    }
                }
            }

            var posts_view = new ViewModels.Page_posts_view();

            posts_view.List_parent_category = lst_parent;
            posts_view.List_parent_all      = lst_parent_all;
            posts_view.List_page_size       = this.GetSizePagingPublic(page_size ?? int.Parse(Util.GetConfigValue("NumberPageSizeNews", "8")));
            posts_view.List_order           = orderDrop;
            posts_view.Page_list_post       = postModels.GetListPostAll(lang, cate_type, cate_id, search, tag, param, (int)page, (int)page_size, order_by, order_type, out total_record);
            posts_view.Total_record         = total_record;
            if (total_record == 0 && search != string.Empty && !string.IsNullOrEmpty(search))
            {
                posts_view.Text_search_result = App_GlobalResources.Lang.strSearchResult;
            }

            posts_view.Order      = order;
            posts_view.Page_size  = page_size ?? int.Parse(Util.GetConfigValue("NumberPageSizeNews", "4"));
            posts_view.Style_list = style_list_show;
            posts_view.Cate_type  = cate_type;
            posts_view.Cate_id    = cate_id ?? 0;
            if (cate != null && (cate.CategoryName == App_GlobalResources.Lang.mnuBeautyTips || cate.CategoryName == App_GlobalResources.Lang.mnuRecruitment))
            {
                posts_view.Cate_name = cate.CategoryName;
            }
            else
            {
                posts_view.Cate_name = string.Empty;
            }

            posts_view.Link              = link_text;
            posts_view.Lang              = lang;
            posts_view.Tag               = tag;
            posts_view.Text_search       = search;
            posts_view.Param             = param;
            posts_view.Parent_action     = HttpContext.Request.RequestContext.RouteData.Values["action"].ToString();
            posts_view.Parent_controller = HttpContext.Request.RequestContext.RouteData.Values["controller"].ToString();

            return(this.PartialView("../control/post_list_all", posts_view));
        }