protected void Page_Load(object sender, EventArgs e) { //if (!this.Page.IsPostBack) //{ //} this.Page.Title = "XXXXXX"; Model_SiteInfo st = new Model_SiteInfo(); Model_MainSetting setting = new Model_MainSetting(); setting = setting.GetMainSetting(); Model_PageEngine PageEngine = new Model_PageEngine(); PageEngine.SiteInfo = st.GetSiteInfo(); Master.PageEngine = PageEngine; //Master.SiteInfo = st.GetSiteInfo(); //Model_MainSetting s = new Model_MainSetting(); Model_Post post = new Model_Post(); string PageSlug = Page.RouteData.Values["PageSlug"] as string; string archive = Page.RouteData.Values["archive"] as string; string slug = Page.RouteData.Values["slug"] as string; if (!string.IsNullOrEmpty(PageSlug)) { string post_slug = PageSlug; content.Text = ""; } if (string.IsNullOrEmpty(PageSlug) && string.IsNullOrEmpty(archive) && string.IsNullOrEmpty(slug)) { string post_slug = string.Empty; int post_id = setting.HomePagePostID; post = post.GetPostByID(post_id); if (post != null) { post_slug = post.Slug; HeaderSection.Text = GenerateHeaderBannerAndSlider(post); content.Text = post.BodyContent; // string[] dd = { "fixed-sidebar", "no-skin-config", "full-height-layout" }; //StyleCore dd = new StyleCore(); //StyleCore.arrayClass = dd; } } }
public static bool InsertMenu(dynamic parameters) { string cmd = parameters["cmd"]; // int cmdarg = (int)parameters["cmdarg"]; string strpost = parameters["strpost"]; string strarch = parameters["strarch"]; string strtax = parameters["strtax"]; string CustomURl = parameters["url"]; string CustomURlTxt = parameters["txt"]; string MenuGroupID = parameters["GroupID"]; Model_PostType cpt = new Model_PostType(); string Title = string.Empty; if (!string.IsNullOrEmpty(cmd)) { switch (cmd) { case "menu_post": if (!string.IsNullOrEmpty(strarch)) { byte PostTypeID = byte.Parse(strarch); Model_PostType cPt = new Model_PostType(); cpt = cpt.GetPostTypeByID(PostTypeID); Model_Menu cme = new Model_Menu(); cme.MGID = int.Parse(MenuGroupID); cme.Title = "All " + cpt.Title; cme.TitleOrigin = cpt.Slug; cme.Slug = cpt.Slug; cme.CustomUrl = ""; cme.Status = true; cme.MenuRefID = 0; cme.Lv = 1; cme.Priority = 1; cme.MCategory = (byte)MenuCategory.Archive; cme.PostTypeID = cpt.PostTypeID; cme.InsertMenuFirst(cme); Model_Archive ma = new Model_Archive(); ma.inSertArchiveMap(cpt.PostTypeID, cpt.Slug); } if (!string.IsNullOrEmpty(strpost)) { foreach (string post in strpost.Split(',')) { int postID = int.Parse(post); Model_Post cP = new Model_Post(); cP = cP.GetPostByID(postID); Model_Menu cme = new Model_Menu(); cme.MGID = int.Parse(MenuGroupID); cme.Title = cP.Slug; cme.TitleOrigin = cP.Slug; cme.Slug = cP.Slug; cme.CustomUrl = ""; cme.Status = true; cme.MenuRefID = 0; cme.Lv = 1; cme.Priority = 1; cme.MCategory = (byte)MenuCategory.Post; cme.PostID = cP.PostID; cme.InsertMenuFirst(cme); } } break; case "menu_Tax": if (!string.IsNullOrEmpty(strtax)) { foreach (string tax in strtax.Split(',')) { int TaxId = int.Parse(tax); Model_PostTaxonomy mp = new Model_PostTaxonomy(); mp = mp.GetTaxonomyByID(TaxId); //if Tax Need to Check PostypeParent and Make Defaul Archive Page as well Model_PostType cPt = new Model_PostType(); cpt = cpt.GetPostTypeByID(mp.PostTypeID); Model_Menu cme = new Model_Menu(); cme.MGID = int.Parse(MenuGroupID); cme.Title = mp.Slug; cme.TitleOrigin = mp.Slug; cme.Slug = mp.Slug; cme.CustomUrl = ""; cme.Status = true; cme.MenuRefID = 0; cme.Lv = 1; cme.Priority = 1; cme.MCategory = (byte)MenuCategory.Taxonomy; cme.TaxID = mp.TaxID; cme.PostTypeID = mp.PostTypeID; cme.InsertMenuFirst(cme); Model_Archive ma = new Model_Archive(); ma.inSertArchiveMap(cpt.PostTypeID, cpt.Slug); } } // mCat = MenuCategory.Taxonomy; break; case "menu_custom": if (!string.IsNullOrEmpty(CustomURl) && !string.IsNullOrEmpty(CustomURlTxt)) { Model_Menu cme = new Model_Menu(); cme.MGID = int.Parse(MenuGroupID); cme.Title = CustomURlTxt; cme.TitleOrigin = CustomURlTxt; cme.Slug = CustomURlTxt; cme.CustomUrl = CustomURl; cme.Status = true; cme.MenuRefID = 0; cme.Lv = 1; cme.Priority = 1; cme.MCategory = (byte)MenuCategory.CustomLink; cme.PostTypeID = cpt.PostTypeID; cme.InsertMenuFirst(cme); } // mCat = MenuCategory.CustomLink; break; } } //Model_Menu cme = new Model_Menu //{ // Title = "", // TitleOrigin = "", // Slug="", // CustomUrl = "", // Status = true, // MenuRefID= 0, // Lv = 1, // IsCustomUrl = true, // Priority=1, // MCategory = (byte)mCat, // TaxID=1, // PostTypeID=1, // PostID = 1 //}; return(true); }
protected void Page_Load(object sender, EventArgs e) { if (!this.Page.IsPostBack) { if (!string.IsNullOrEmpty(Request.QueryString["PostID"])) { int PostID = int.Parse(Request.QueryString["PostID"]); Model_Post p = new Model_Post(); p = p.GetPostByID(PostID); if (p != null) { //string btnEdit = "<select name=\"content_status\" class=\"form-control\"><option "+ (p.Status ? "Selected=\"Selected\"" : "") + " value=\"True\" >Publish</option><option "+ (!p.Status ? "Selected=\"Selected\"" : "") + " value=\"False\">Draft</option></select>"; dropStatus.SelectedValue = p.Status.ToString(); //"<label>" + (p.Status ? "Published" : "Draft") + "</label>" + lbldatepublish.Text = p.DatePublish.ToThaiDateTime().ToString("dd MMM yyyy HH:mm tt"); txtTitle.Text = p.Title; txtContent.Text = p.BodyContent; txtContentBuilder.Text = p.BodyContentBuilder; //Model_MainSetting setting = new Model_MainSetting(); //setting = setting.GetMainSetting(); url.Text = this.MainSetting.WebSiteURL + (p.PostTypeID != 1 ? p.PostTypeClass.Slug + "/" : string.Empty); slug.Text = p.Slug; viewcount.Text = p.ViewCount.ToString(); if (p.Trash) { linktrash.Visible = true; linkrestore.Visible = false; } else { linktrash.Visible = false; linkrestore.Visible = true; } CoverType.Value = p.BannerTypeID.ToString(); radioshowmMS.SelectedValue = p.ShowMasterSlider.ToString(); if (p.PostSEO != null) { Model_PostSeo seo = p.PostSEO; seotitle.Text = seo.SEOTitle; metades.Text = seo.MetaDescription; Canonical.Text = seo.CanonicalUrl; droprebot.SelectedValue = seo.Metarobotsfollow.ToString(); facebookTitle.Text = seo.FaceBookTitle; facebookDes.Text = seo.FacebookDescription; facebookImg.Value = seo.FacebookImage; twTitle.Text = seo.TwitterTitle; twDes.Text = seo.TwitterDescription; twimg.Value = seo.TwitterImages; analytic.Text = seo.GoogleAnalytic; } if (p.PostMedia.Count > 0) { Model_PostMedia cover = p.PostMedia.FirstOrDefault(r => r.PostID == PostID && r.PostMediaTypeID == PostMediaType.CoverImage); if (cover != null) { hd_MID.Value = cover.MID.ToString(); CoverImage1.Value = cover.MediaFullPath; //hd_postMeidaID.Value = cover.PostMediaID.ToString(); } Model_PostMedia feature = p.PostMedia.FirstOrDefault(r => r.PostID == PostID && r.PostMediaTypeID == PostMediaType.FeatureImage); if (feature != null) { feature_image_mid.Value = feature.MID.ToString(); feature_image_url.Value = feature.MediaFullPath; //hd_postMeidaID.Value = cover.PostMediaID.ToString(); } } //Chcek Defaul Postype Field Charactor //if PostType = product if (p.PostTypeID == (byte)PostType.Products) { Model_TaxMap ctm = new Model_TaxMap(); List <Model_TaxMap> ctm_cat = ctm.GetTaxByPostIDandTaxType(PostID, (byte)PostTaxonomyType.Categories); List <Model_TaxMap> ctm_tag = ctm.GetTaxByPostIDandTaxType(PostID, (byte)PostTaxonomyType.Tags); pn_product_default.Visible = true; Model_PostTaxonomy pt = new Model_PostTaxonomy { PostTypeID = p.PostTypeID, TaxTypeID = (byte)PostTaxonomyType.Categories }; List <Model_PostTaxonomy> Taxlist = pt.GetTaxonomyActiveOnly(pt); CategoryTax.Text = getCatProduct(Taxlist, ctm_cat); Model_PostTaxonomy pttags = new Model_PostTaxonomy { PostTypeID = p.PostTypeID, TaxTypeID = (byte)PostTaxonomyType.Tags }; List <Model_PostTaxonomy> TaxlistTags = pt.GetTaxonomyActiveOnly(pttags); TagsTax.Text = getTagsProductList(TaxlistTags, ctm_tag); List <Model_PostMedia> gall = p.PostMedia.Where(r => r.PostID == PostID && r.PostMediaTypeID == PostMediaType.Gallery).ToList(); if (gall.Count() > 0) { string ele = string.Empty; foreach (Model_PostMedia m in gall) { string mid = m.MID.ToString(); ele += "<div class=\"media_item_box_gall\" id=\"media_item_box_gall_" + mid + "\" style=\"margin-top:5px;\">"; ele += "<label class=\"box_media_fucus_block\" onclick=\"return false;\" style=\"background-image: url(" + m.MediaFullPath + ");\"><button data-idmediab=\"media_item_box_8\" onclick=\"removeMedia_gall(this);\" class=\"btn btn-warning btn-circle btn-media-focus\" type=\"button\"><i class=\"fa fa-times\"></i></button></label>"; ele += "<input type=\"checkbox\" checked=\"checked\" name=\"checkGall\" style=\"display:none;\" value=\"" + mid + "\">"; ele += "<input type=\"hidden\" name=\"p_gall_" + mid + "\" id=\"p_gall_" + mid + "\" value=\"" + m.MediaFullPath + "\">"; ele += "<input type=\"hidden\" name=\"p_gall_mid" + mid + "\" id=\"p_gall_mid" + mid + "\" value=\"" + mid + "\">"; ele += "<input type=\"hidden\" name=\"p_gall_pri" + mid + "\" id=\"p_gall_pri" + mid + "\"value=\"" + m.Priority + "\">"; ele += "</div>"; } //hd_MID.Value = cover.MID.ToString(); //CoverImage1.Value = this.MainSetting.WebSiteURL + cover.MediaFullPath; //hd_postMeidaID.Value = cover.PostMediaID.ToString(); gal_server.Text = ele; } //check price for product Model_PostPricing pp = new Model_PostPricing(); List <Model_PostPricing> ppl = pp.GetPostPriceAllByPostID(PostID); if (ppl.Count < 1) { pp.PostID = PostID; pp.Isvat = true; pp.Price = 0.0m; pp.PostTypeID = (byte)PostType.Products; pp.Title = string.Empty; int priceid = pp.InsertPrice(pp); hd_productPrice_id.Value = priceid.ToString(); pp = pp.GetPostPriceAllByID(priceid); priceVat.SelectedValue = pp.Isvat.ToString(); txtPriceTitle.Text = pp.Title; txtProductPrice.Text = pp.Price.ToString("#,##0.00"); } else { pp = ppl[0]; hd_productPrice_id.Value = pp.PriceID.ToString(); priceVat.SelectedValue = pp.Isvat.ToString(); txtProductPrice.Text = pp.Price.ToString("#,##0.00"); txtPriceTitle.Text = pp.Title; if (pp.PriceOPtion.Count > 0) { droppriceOPtion.DataSource = pp.PriceOPtion; droppriceOPtion.DataValueField = "Title"; droppriceOPtion.DataTextField = "PriceOptionID"; droppriceOPtion.DataBind(); dropOptionQty.DataSource = pp.PriceOPtionQty; dropOptionQty.DataValueField = "QtyOPtionDrop"; dropOptionQty.DataTextField = "QtyID"; dropOptionQty.DataBind(); } } } //Check Cutom Post Field Model_PostCustomGroup pct = new Model_PostCustomGroup(); List <Model_PostCustomGroup> pctList = pct.getCustomByPostID(PostID); foreach (Model_PostCustomGroup pci in pctList) { switch (pci.PcGroupName) { case "HomeGroup": pn_home_custom.Visible = true; List <Model_PostCustomItem> itemList = pci.CustomItem; Model_PostCustomItem bannerAnn = itemList.SingleOrDefault(r => r.PcName == "banner-announce"); if (bannerAnn != null) { b1_url.Value = bannerAnn.URL; b1_id.Value = bannerAnn.MID.ToString(); banner_home_1.Text = bannerAnn.Caption1; } Model_PostCustomItem bannerright = itemList.SingleOrDefault(r => r.PcName == "banner-announce-right"); if (bannerright != null) { b2_url.Value = bannerright.URL; b2_id.Value = bannerright.MID.ToString(); banner_home_2.Text = bannerright.Caption1; } //"banner-announce" //banner-announce-right //banner-client drop_b_client_ret.DataSource = itemList.Where(r => r.PcName == "banner-client"); //drop_b_client_ret.DataTextFormatString = "{0} - {1}"; drop_b_client_ret.DataTextField = "MID"; //drop_b_client_ret.DataTextField = "Caption1"; drop_b_client_ret.DataValueField = "DropTextFile"; drop_b_client_ret.DataBind(); break; case "ProductGroup": pn_product_custom.Visible = true; main_post_content.Visible = false; //TagsTax //bing //product_detail = 1, //product_information = 2, //product_b_announce = 3, //product_b_rigth = 4 //product_code = 5, //product_quantity = 6, //product_price_per_unit = 7 List <Model_PostCustomItem> ProductitemList = pci.CustomItem; Model_PostCustomItem PbannerAnn = ProductitemList.SingleOrDefault(r => r.PcName == "product-b-announce"); if (PbannerAnn != null) { p_banner_ann_8.Value = PbannerAnn.URL; p_banner_ann_mid_8.Value = PbannerAnn.MID.ToString(); p_banner_ann_caption.Text = PbannerAnn.Caption1; } Model_PostCustomItem Pbannerright = ProductitemList.SingleOrDefault(r => r.PcName == "product-b-rigth"); if (Pbannerright != null) { p_banner_9.Value = Pbannerright.URL; p_banner_mid_9.Value = Pbannerright.MID.ToString(); p_banner_rigth.Text = Pbannerright.Caption1; } Model_PostCustomItem P_pro_de = ProductitemList.SingleOrDefault(r => r.PcName == "product-detail"); if (P_pro_de != null) { ProductDetail.Text = P_pro_de.ContentHTML; } Model_PostCustomItem P_pro_info = ProductitemList.SingleOrDefault(r => r.PcName == "product-information"); if (P_pro_info != null) { ProductInformation.Text = P_pro_info.ContentHTML; } //xtData = @TextData,PriceData = @PriceData,NumData = @NumData Model_PostCustomItem P_pro_code = ProductitemList.SingleOrDefault(r => r.PcName == "product-code"); if (P_pro_code != null) { txtProductCode.Text = P_pro_code.TextData; } Model_PostCustomItem P_pro_quan = ProductitemList.SingleOrDefault(r => r.PcName == "product-quantity"); if (P_pro_quan != null) { txtProductQuantity.Text = P_pro_quan.NumData.HasValue ? P_pro_quan.NumData.ToString() : string.Empty; } //Model_PostCustomItem P_pro_price = ProductitemList.SingleOrDefault(r => r.PcName == "product-price-per-unit"); //if (P_pro_price != null) //{ // txtProductPrice.Text = P_pro_price.PriceData.HasValue ? ((decimal)P_pro_price.PriceData).ToString("#,###.00") : string.Empty; //} break; } } } } } }
public static Model_Post GetPostByID(int PostID) { Model_Post post = new Model_Post(); return(post.GetPostByID(PostID)); }