示例#1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!this.Page.IsPostBack)
        {
            Model_Post cpost = new Model_Post
            {
                PostTypeID = 1
            };

            dropPost.DataSource     = cpost.GetPostListByPostType(cpost);
            dropPost.DataValueField = "PostID";
            dropPost.DataTextField  = "Title";
            dropPost.DataBind();


            ListItem li = new ListItem("Select", "0");
            dropPost.Items.Insert(0, li);
            //Model_Setting c = new Model_Setting();
            Model_MainSetting m = new Model_MainSetting();
            m = m.GetMainSetting();
            //c = c.GetSetting();
            if (m != null)
            {
                tagline.Text = m.TagLine;
                wsurl.Text   = m.WebSiteURL;
                wsTitle.Text = m.WebSiteTitle;
                dropStiteLang.SelectedValue = m.SiteLang.ToString();
                timezone_string.Value       = m.UTC.ToString();
                dropPost.SelectedValue      = m.HomePagePostID.ToString();
            }
        }
    }
示例#2
0
    public static void GetAll(Model_Post parameters)
    {
        //Model_Post p = new Model_Post { PostTypeID = 1 };
        IList <Model_Post> ret = parameters.GetPostListByPostType(parameters);


        AppTools.SendResponse(HttpContext.Current.Response, ret.ObjectToJSON());
    }
示例#3
0
    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;
            }
        }
    }
示例#4
0
    protected void linktrash_Click(object sender, EventArgs e)
    {
        int  intPostID     = int.Parse(Request.QueryString["PostID"]);
        byte intPostTypeID = byte.Parse(Request.QueryString["PostTypeID"]);

        Model_Post p = new Model_Post();

        if (p.UPDATETrash(intPostID, false))
        {
            Response.Redirect("Edit?PostTypeID=" + intPostTypeID);
        }
    }
示例#5
0
        public ActionResult Group(Guid id)
        {
            var group = new DbController.Model_Group().Select().Where(x => x.OtherProps.Id == id).FirstOrDefault().OtherProps;

            ViewBag.Title = group.Name;
            ViewBag.Id    = group.Id.ToString();
            var posts = new Model_Post().Select().Where(x => x.GroupId == id).Select(x => new v_Post {
                Abstract = x.Abstract, AdminUsername = x.AdminUsername, Date = x.Date, Title = x.Title, Id = x.Id
            }).OrderByDescending(x => x.Date).Take(30);

            return(View(posts));
        }
示例#6
0
    protected void linkrestore_Click(object sender, EventArgs e)
    {
        int intPostID = int.Parse(Request.QueryString["PostID"]);
        //byte intPostTypeID = byte.Parse(Request.QueryString["PostTypeID"]);

        Model_Post p = new Model_Post();

        if (p.UPDATETrash(intPostID, true))
        {
            Response.Redirect(Request.Url.ToString());
        }
    }
示例#7
0
    private string GenerateHeaderBannerAndSlider(Model_Post post)
    {
        string ret = string.Empty;

        if (post.ShowMasterSlider)
        {
            ret = Slider();
        }
        else
        {
            ret = breadcrumb(post.BannerTypeID);
        }

        return(ret);
    }
示例#8
0
    protected void btnPubish_Click(object sender, EventArgs e)
    {
        Model_Post p = new Model_Post
        {
            PostTypeID         = byte.Parse(Request.QueryString["PostTypeID"]),
            Title              = txtTitle.Text.Trim(),
            Short              = "",
            Slug               = txtTitle.Text.GenerateSlug(),
            DateSubmit         = DatetimeHelper._UTCNow(),
            UserID             = this.UserActive.UserID,
            DatePublish        = DatetimeHelper._UTCNow(),
            Status             = bool.Parse(dropStatus.SelectedValue),
            ShowComment        = false,
            BodyContent        = txtContent.Text.Trim(),
            BodyContentBuilder = "",
            BannerTypeID       = byte.Parse(CoverType.Value),
            ShowMasterSlider   = bool.Parse(radioshowmMS.SelectedValue),
            ViewCount          = 1
        };

        int postid = p.InsertPost(p);

        if (postid > 0 && byte.Parse(Request.QueryString["PostTypeID"]) == (byte)PostType.Products)
        {
            Model_PostPricing pp = new Model_PostPricing
            {
                PostID     = postid,
                Isvat      = true,
                Price      = 0.0m,
                PostTypeID = (byte)PostType.Products,
                Title      = string.Empty
            };
            pp.InsertPrice(pp);
        }

        if (postid > 0)
        {
            Response.Redirect("Post?PostID=" + postid);
        }

        //Response.Write(txtContent.Text);
        //Response.End();
    }
示例#9
0
        /// <summary>
        /// Guarda el objetivo de manera asíncrona
        /// </summary>
        /// <param name="item">el objeto</param>
        /// <returns>Tarea.</returns>
        public async Task SaveTodoItemAsync(Model_Post item)
        {
            var uri = new Uri(string.Format("http://192.168.1.21/proyectobdSigma/objetivo/" + RestClient <UserDetailsCredentials> .idMiembro, string.Empty));

            try
            {
                var json    = JsonConvert.SerializeObject(item);
                var content = new StringContent(json, Encoding.UTF8, "application/json");

                HttpResponseMessage response = null;

                response = await _client.PutAsync(uri, content);


                if (response.IsSuccessStatusCode)
                {
                    Debug.WriteLine(@"\tTodoItem successfully saved.");
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(@"\tERROR {0}", ex.Message);
            }
        }
    private string GenerateHeaderBannerAndSlider(Model_Post post, Model_PostTaxonomy tax = null)
    {
        string ret = string.Empty;

        //case Post
        //The Post Can Manange Show Master Slide Or Type of Banner cover page.
        if (post != null)
        {
            if (post.ShowMasterSlider)
            {
                ret = Slider();
            }
            else
            {
                ret = breadcrumb(post.BannerTypeID);
            }
            if (post.BannerTypeID == 1)
            {
                ret = ret.Replace("<!--##THE_TITLE##-->", post.Title);
            }

            List <Model_PostMedia> pml = post.PostMedia;

            Model_PostMedia pm = pml.SingleOrDefault(m => m.PostMediaTypeID == PostMediaType.CoverImage);
            if (pm != null)
            {
                ret = ret.Replace("<!--##THE_COVER##-->", pm.MediaFullPath);
            }
        }
        else
        {
            //case Archive Page
            // Can display Title postype name only.
            if (tax != null)
            {
                if (tax.ShowMasterSlider)
                {
                    ret = Slider();
                }
                else
                {
                    ret = breadcrumb(tax.BannerTypeID);
                }

                if (tax.BannerTypeID == 1)
                {
                    ret = ret.Replace("<!--##THE_TITLE##-->", tax.Title);
                }

                List <Model_TaxMedia> pml = tax.TaxMedia;

                Model_TaxMedia pm = pml.SingleOrDefault(m => m.TaxMediaTypeID == TaxMediaType.CoverImage);
                if (pm != null)
                {
                    ret = ret.Replace("<!--##THE_COVER##-->", pm.MediaFullPath);
                }
            }
            else
            {
                ret = breadcrumb(2);
            }
        }


        return(ret);
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        //Response.Write(HttpUtility.UrlDecode(Request.Url.AbsolutePath)));Response.End();
        if (!this.Page.IsPostBack)
        {
            string Pagetitle       = string.Empty;
            string Pagedescription = string.Empty;
            string canonical       = string.Empty;
            string fb_localte      = string.Empty;
            string fb_type         = string.Empty;
            string fb_title        = string.Empty;
            string fb_des          = string.Empty;
            string fb_url          = string.Empty;
            string fb_site_name    = string.Empty;
            string fb_image        = string.Empty;

            string tw_card  = string.Empty;
            string tw_title = string.Empty;
            string tw_des   = string.Empty;
            string tw_image = string.Empty;


            string analytic        = string.Empty;
            bool   Metarobotfollow = false;

            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();
            PageEngine.MainSetting = setting;
            Model_PostType     cPostType   = new Model_PostType();
            Model_Post         post        = new Model_Post();
            Model_Menu         m           = new Model_Menu();
            Model_PostTaxonomy tax         = new Model_PostTaxonomy();
            List <Model_Post>  postArchive = new List <Model_Post>();
            Model_Archive      archive     = new Model_Archive();

            PageEngine.NavMenu    = m.GetMenuAll(1);
            PageEngine.FooterMenu = m.GetMenuAll(2);

            //string[] dd = { "fixed-sidebar", "no-skin-config", "full-height-layout" };
            //StyleCore dd = new StyleCore();
            //StyleCore.arrayClass = dd;


            //Set Setting to MasterPage Class
            Master.PageEngine = PageEngine;



            byte   bytPostTypeID = 0;
            string StrPost_slug  = string.Empty;
            int    intPostID     = 0;


            string RouteSlug_1       = Page.RouteData.Values["Param1"] as string;
            string RouteSlug_2       = Page.RouteData.Values["Param2"] as string;
            string RouteSlug_3       = Page.RouteData.Values["Param3"] as string;
            string RouteSlug_4       = Page.RouteData.Values["Param4"] as string;
            string RouteSlug_5       = Page.RouteData.Values["Param5"] as string;
            Model_PostCustomItem pct = new Model_PostCustomItem();

            //Case Route Slug
            if (!string.IsNullOrEmpty(RouteSlug_1))
            {
                //1. Check Is Archive

                archive = archive.GetPostArchive(RouteSlug_1);


                if (archive != null)
                {
                    //Is Archive
                    bytPostTypeID = archive.PostTypeID;
                    StrPost_slug  = (string.IsNullOrEmpty(archive.Slug) ? archive.PostTypeSlug : archive.Slug);

                    //postArchive = CmsController.GetPostArchive(bytPostTypeID);

                    //Check  PostType Archive
                    switch (StrPost_slug)
                    {
                    case "hotelworld-products":
                        //check Route Param2
                        if (string.IsNullOrEmpty(RouteSlug_2))
                        {
                            //Case Product Page Archive
                            SectionProductArchive.Visible = true;

                            cPostType = cPostType.GetPostTypeBySlug(StrPost_slug);
                            if (cPostType != null)
                            {
                                //product-type = 24
                                this.TaxForPostType = tax.FrontGetTaxonomyByID(24);

                                if (this.TaxForPostType != null)
                                {
                                    this.TaxList = tax.FrontGetTaxonomyByRefID(24);
                                }
                            }
                        }
                        else
                        {
                            //check Is Paging of Product Page Archive
                            if (RouteSlug_2 == "page")
                            {
                                //Case Archive Paging
                                SectionProductArchive.Visible = true;
                                string pageno = RouteSlug_3;
                            }
                            else if (RouteSlug_2 == "category" || RouteSlug_2 == "tag")
                            {
                                //Tax Archive

                                tax = tax.GetTaxBySlugAndPostType(RouteSlug_3, bytPostTypeID);
                                if (tax != null)
                                {
                                    //case Tax approve
                                    SectionProductTaxArchive.Visible = true;
                                    this.TaxForPostType = tax;
                                    this.TaxList        = tax.GetTaxonomyTaxTypeAndPostType_withcountpost(bytPostTypeID, (byte)PostTaxonomyType.Categories);
                                    this.ContentBody    = tax.BodyContent;
                                    //Case tax Archive Paging
                                    if (RouteSlug_4 == "page")
                                    {
                                        string pageno = RouteSlug_5;

                                        //Do something with paging
                                    }
                                }
                            }
                            else
                            {
                                //Check Product SinglePage
                                post = CmsController.GetPostSlug(RouteSlug_2, PostType.Products);
                                if (post != null)
                                {
                                    SectionProductSingle.Visible = true;
                                    this.PostDataUI       = post;
                                    this.ContentBody      = post.BodyContent;
                                    this.PageContentTitle = post.Title;
                                    this.CTF = pct.GetItemCustomByPostID(post.PostID);
                                }
                            }
                        }


                        break;

                    case "ข่าวสาร":

                        //check Route Param2
                        if (string.IsNullOrEmpty(RouteSlug_2))
                        {
                            //Case Product Page Archive
                            SectionBlogPageArchive.Visible = true;
                        }
                        else
                        {
                            //check Is Paging of Product Page Archive
                            if (RouteSlug_2 == "page")
                            {
                                //Case Archive Paging
                                SectionBlogPageArchive.Visible = true;
                                string pageno = RouteSlug_3;
                            }
                            else if (RouteSlug_2 == "category" || RouteSlug_2 == "tag")
                            {
                                //Tax Archive

                                tax = tax.GetTaxBySlugAndPostType(RouteSlug_3, bytPostTypeID);
                                if (tax != null)
                                {
                                    //case Tax approve
                                    //Same layout with blog archive
                                    // SectionBlogPageTaxArchive.Visible = true;
                                    SectionBlogPageArchive.Visible = true;

                                    //Case tax Archive Paging
                                    if (RouteSlug_4 == "page")
                                    {
                                        string pageno = RouteSlug_5;

                                        //Do something with paging
                                    }
                                }
                            }
                            else
                            {
                                //Check Product SinglePage
                                post = CmsController.GetPostSlug(RouteSlug_2, PostType.Blog);
                                if (post != null)
                                {
                                    SectionBlogPageSingle.Visible = true;
                                }
                            }
                        }

                        break;
                    }
                    HeaderSection.Text = GenerateHeaderBannerAndSlider(post, tax);
                }
                else
                {
                    //Case PostType Page
                    StrPost_slug = RouteSlug_1;
                    post         = CmsController.GetPostSlug(StrPost_slug, PostType.Pages);

                    if (post != null)
                    {
                        bytPostTypeID = post.PostTypeID;
                        intPostID     = post.PostID;

                        //page_header.Visible = true;

                        if (StrPost_slug == "checkout")
                        {
                            section_checkout_page.Visible = true;
                        }
                        else
                        {
                            page_content.Visible = true;
                        }



                        HeaderSection.Text    = GenerateHeaderBannerAndSlider(post);
                        this.PostDataUI       = post;
                        this.ContentBody      = post.BodyContent;
                        this.PageContentTitle = post.Title;
                    }
                }


                // content.Text = post.BodyContent;
            }
            else
            {
                //Case HomePage No Slug
                //Get PostID From Setting HomePage Slug

                intPostID = setting.HomePagePostID;
                post      = CmsController.GetPostByID(intPostID);

                if (post != null)
                {
                    StrPost_slug = post.Slug;

                    bytPostTypeID      = post.PostTypeID;
                    HeaderSection.Text = GenerateHeaderBannerAndSlider(post);


                    this.CTF = pct.GetItemCustomByPostID(intPostID);


                    // content.Text = post.BodyContent;
                    this.PostDataUI           = post;
                    this.ContentBody          = post.BodyContent;
                    this.PageContentTitle     = post.Title;
                    section_page_home.Visible = true;


                    home_content.Text = this.ContentBody;
                }
            }

            //= null;
            Model_PostSeo posttype_postseo = new Model_PostSeo();
            Model_PostSeo tax_postseo      = new Model_PostSeo();
            Model_PostSeo post_postseo     = new Model_PostSeo();
            if (bytPostTypeID != 0)
            {
                cPostType        = cPostType.GetPostTypeByID(bytPostTypeID);
                posttype_postseo = cPostType.PosTypetSEO;
            }


            if (tax != null)
            {
                tax_postseo = tax.TaxSEO;
            }

            if (post != null)
            {
                post_postseo = post.PostSEO;
            }


            Pagetitle       = checklv(posttype_postseo, tax_postseo, post_postseo, "SEOTitle");
            Pagedescription = checklv(posttype_postseo, tax_postseo, post_postseo, "MetaDescription");
            canonical       = checklv(posttype_postseo, tax_postseo, post_postseo, "CanonicalUrl");
            fb_localte      = setting.htmlTagSiteLang;
            fb_type         = "website";
            fb_title        = checklv(posttype_postseo, tax_postseo, post_postseo, "FaceBookTitle");
            fb_des          = checklv(posttype_postseo, tax_postseo, post_postseo, "FacebookDescription");
            fb_url          = Request.Url.ToString();
            fb_site_name    = PageEngine.SiteInfo.Slogan;
            fb_image        = checklv(posttype_postseo, tax_postseo, post_postseo, "FacebookImage");
            tw_card         = "summary";
            tw_title        = checklv(posttype_postseo, tax_postseo, post_postseo, "TwitterTitle");
            tw_des          = checklv(posttype_postseo, tax_postseo, post_postseo, "TwitterDescription");
            tw_image        = checklv(posttype_postseo, tax_postseo, post_postseo, "TwitterImages");

            analytic = checklv(posttype_postseo, tax_postseo, post_postseo, "GoogleAnalytic");

            Metarobotfollow = checklv_bool(posttype_postseo, tax_postseo, post_postseo, "Metarobotsfollow");

            this.Page.Title = string.IsNullOrEmpty(Pagetitle) ? setting.WebSiteTitle : Pagetitle;

            var MetaDescription = new HtmlMeta {
                Name = "description", Content = Pagedescription
            };
            Header.Controls.Add(MetaDescription);

            var MetaFB_locate = new HtmlMeta {
                Name = "og:locale", Content = fb_localte
            };
            Header.Controls.Add(MetaFB_locate);

            var MetaFB_Type = new HtmlMeta {
                Name = "og:type", Content = fb_type
            };
            Header.Controls.Add(MetaFB_Type);

            var MetaFB_title = new HtmlMeta {
                Name = "og:title", Content = !string.IsNullOrEmpty(fb_title)? fb_title :   string.IsNullOrEmpty(Pagetitle) ? setting.WebSiteTitle : Pagetitle
            };
            Header.Controls.Add(MetaFB_title);


            var MetaFB_Des = new HtmlMeta {
                Name = "og:description", Content = !string.IsNullOrEmpty(fb_des) ? fb_des: Pagedescription
            };
            Header.Controls.Add(MetaFB_Des);

            var MetaFB_Url = new HtmlMeta {
                Name = "og:url", Content = fb_url
            };
            Header.Controls.Add(MetaFB_Url);

            var MetaFB_SiteName = new HtmlMeta {
                Name = "og:site_name", Content = fb_site_name
            };
            Header.Controls.Add(MetaFB_SiteName);

            var MetaFB_image = new HtmlMeta {
                Name = "og:image", Content = fb_image
            };
            Header.Controls.Add(MetaFB_image);

            var MetaTW_Card = new HtmlMeta {
                Name = "twitter:card", Content = tw_card
            };
            Header.Controls.Add(MetaTW_Card);

            var MetaTW_Des = new HtmlMeta {
                Name = "twitter:description", Content = tw_des
            };
            Header.Controls.Add(MetaTW_Des);
            var MetaTW_Title = new HtmlMeta {
                Name = "twitter:title", Content = tw_title
            };
            Header.Controls.Add(MetaTW_Title);
            var Meta_Image = new HtmlMeta {
                Name = "twitter:image", Content = tw_image
            };
            Header.Controls.Add(Meta_Image);
        }
    }
 /// <summary>
 /// Borra Objetivo
 /// </summary>
 /// <param name="item">The item.</param>
 /// <returns>Task.</returns>
 public Task DeleteTaskAsync(Model_Post item)
 {
     return(restService.DeleteTodoItemAsync(item.id));
 }
 /// <summary>
 /// Guarda Objetivo
 /// </summary>
 /// <param name="item">The item.</param>
 /// <returns>Task.</returns>
 public Task SaveTaskAsync(Model_Post item)
 {
     return(restService.SaveTodoItemAsync(item));
 }
    public static Model_Post GetPostByID(int PostID)
    {
        Model_Post post = new Model_Post();

        return(post.GetPostByID(PostID));
    }
示例#15
0
    protected void btnPubish_Click(object sender, EventArgs e)
    {
        if (!string.IsNullOrEmpty(Request.QueryString["PostID"]))
        {
            int intPostID = int.Parse(Request.QueryString["PostID"]);

            Model_Post p = new Model_Post
            {
                PostID             = intPostID,
                PostTypeID         = 1,
                Title              = txtTitle.Text.Trim(),
                Short              = "",
                Slug               = slug.Text.GenerateSlug(),
                DateSubmit         = DatetimeHelper._UTCNow(),
                UserID             = this.UserActive.UserID,
                DatePublish        = DatetimeHelper._UTCNow(),
                Status             = bool.Parse(dropStatus.SelectedValue),
                ShowComment        = false,
                BodyContent        = txtContent.Text.Trim(),
                BodyContentBuilder = txtContentBuilder.Text.Trim(),
                BannerTypeID       = byte.Parse(CoverType.Value),
                ShowMasterSlider   = bool.Parse(radioshowmMS.SelectedValue),
                ViewCount          = 1
            };


            Model_PostSEOMap seomap = new Model_PostSEOMap();
            seomap = seomap.GetSEOID(intPostID);

            Model_PostSeo seo = new Model_PostSeo {
                SEOTitle            = seotitle.Text.Trim(),
                MetaDescription     = metades.Text.Trim(),
                CanonicalUrl        = Canonical.Text.Trim(),
                Metarobotsfollow    = bool.Parse(droprebot.SelectedValue),
                FaceBookTitle       = facebookTitle.Text.Trim(),
                FacebookDescription = facebookDes.Text.Trim(),
                FacebookImage       = facebookImg.Value,
                TwitterTitle        = twTitle.Text.Trim(),
                TwitterDescription  = twDes.Text.Trim(),
                TwitterImages       = twimg.Value,
                GoogleAnalytic      = analytic.Text.Trim(),
            };


            Model_PostPricing pp = new Model_PostPricing();
            if (!string.IsNullOrEmpty(hd_productPrice_id.Value))
            {
                pp = pp.GetPostPriceAllByID(int.Parse(hd_productPrice_id.Value));
            }


            if (pp != null)
            {
                Model_PostPricing pu = new Model_PostPricing
                {
                    Price   = string.IsNullOrEmpty(txtProductPrice.Text)? 0: decimal.Parse(txtProductPrice.Text),
                    PriceID = pp.PriceID,
                    Isvat   = bool.Parse(priceVat.SelectedValue),

                    Title = txtPriceTitle.Text
                };
                pu.UpdataPostPrice(pu);

                Model_PostPricingOption    cpo = new Model_PostPricingOption();
                Model_PostPricingOptionQty cq0 = new Model_PostPricingOptionQty();
                cq0.DeleteOPtionPriceQty(pp.PriceID);
                cpo.DeleteOPtionPrice(pp.PriceID);

                string po = Request.Form["chk_price_option"];
                if (!string.IsNullOrEmpty(po))
                {
                    string[] arrpo = po.Split(',');
                    foreach (string poi in arrpo)
                    {
                        Model_PostPricingOption cpoi = new Model_PostPricingOption();
                        cpoi.PriceID = pp.PriceID;
                        cpoi.Title   = Request.Form["po_title_s_" + poi];

                        int cp = cpoi.InsertPriceOPtion(cpoi);

                        string q = Request.Form["chk_price_option_qty_" + poi];
                        if (!string.IsNullOrEmpty(q))
                        {
                            string[] arrq = q.Split(',');
                            foreach (string qq in arrq)
                            {
                                Model_PostPricingOptionQty cq = new Model_PostPricingOptionQty();
                                cq.PriceID       = pp.PriceID;
                                cq.PriceOptionID = cp;
                                cq.UnitFrom      = string.IsNullOrEmpty(Request.Form["po_from_s_q" + poi + "_" + qq]) ? 1 : int.Parse(Request.Form["po_from_s_q" + poi + "_" + qq]);
                                cq.UnitTo        = string.IsNullOrEmpty(Request.Form["po_to_s_q" + poi + "_" + qq]) ? 0 : int.Parse(Request.Form["po_to_s_q" + poi + "_" + qq]);
                                cq.PriceOption   = string.IsNullOrEmpty(Request.Form["po_p_s_q" + poi + "_" + qq]) ? 0 : decimal.Parse(Request.Form["po_p_s_q" + poi + "_" + qq]);
                                cq.InsertPriceOPtionQty(cq);
                            }
                        }
                    }
                }
            }

            if (seomap != null)
            {
                seo.PSID = seomap.PSID;
                seo.UpdateSEO(seo);
            }
            else
            {
                int PSID = seo.InsertSEO_step1(seo);
                if (PSID > 0)
                {
                    seomap = new Model_PostSEOMap
                    {
                        PostID = intPostID,
                        PSID   = PSID
                    };

                    seomap.InsertMApSeo(seomap);
                }
            }

            //Cover
            if (!string.IsNullOrEmpty(hd_MID.Value))
            {
                Model_PostMedia pm = new Model_PostMedia
                {
                    PostMediaTypeID = PostMediaType.CoverImage,
                    PostID          = intPostID,
                    MID             = int.Parse(hd_MID.Value)
                };

                pm.insertMediaPost(pm);
            }
            else
            {
                Model_PostMedia pm = new Model_PostMedia
                {
                    PostMediaTypeID = PostMediaType.CoverImage,
                    PostID          = intPostID
                };

                pm.DeletePostMedia(pm);
            }

            //Feature image
            if (!string.IsNullOrEmpty(feature_image_mid.Value))
            {
                Model_PostMedia pm = new Model_PostMedia
                {
                    PostMediaTypeID = PostMediaType.FeatureImage,
                    PostID          = intPostID,
                    MID             = int.Parse(feature_image_mid.Value)
                };

                pm.insertMediaPost(pm);
            }
            else
            {
                Model_PostMedia pm = new Model_PostMedia
                {
                    PostMediaTypeID = PostMediaType.FeatureImage,
                    PostID          = intPostID
                };

                pm.DeletePostMedia(pm);
            }



            //Check Cutom Post Field
            Model_PostCustomGroup        pct     = new Model_PostCustomGroup();
            List <Model_PostCustomGroup> pctList = pct.getCustomByPostID(intPostID);

            if (pctList.SingleOrDefault(i => i.PcGroupName == "HomeGroup") != null)
            {
                //"HomeGroup":
                //banner announce
                Model_PostCustomItem cpi = new Model_PostCustomItem();
                cpi.PostID      = intPostID;
                cpi.PCDID       = (int)CustomGroup.HomeGroup;
                cpi.PcGroupName = "HomeGroup";
                cpi.MID         = !string.IsNullOrEmpty(b1_id.Value) ? int.Parse(b1_id.Value) : 0;
                cpi.Caption1    = banner_home_1.Text.Trim();
                cpi.URL         = b1_url.Value;
                cpi.PcName      = "banner-announce";

                cpi.ClearCustomByPostIDandName(intPostID, "banner-announce");
                cpi.Insert(cpi);


                //banner left
                Model_PostCustomItem cpi_1 = new Model_PostCustomItem();
                cpi_1.PCDID       = (int)CustomGroup.HomeGroup;
                cpi_1.PostID      = intPostID;
                cpi_1.PcGroupName = "HomeGroup";
                cpi_1.MID         = !string.IsNullOrEmpty(b2_id.Value) ? int.Parse(b2_id.Value) : 0;
                cpi_1.Caption1    = banner_home_2.Text.Trim();
                cpi_1.URL         = b2_url.Value;
                cpi_1.PcName      = "banner-announce-right";
                cpi_1.ClearCustomByPostIDandName(intPostID, "banner-announce-right");
                cpi_1.Insert(cpi_1);



                //banner
                Model_PostCustomItem cpi_2_c = new Model_PostCustomItem();
                cpi_2_c.ClearCustomByPostIDandName(intPostID, "banner-client");
                string chk_banner_client = Request.Form["chk_banner_client"];
                if (!string.IsNullOrEmpty(chk_banner_client))
                {
                    string[] arr = chk_banner_client.Split(',');
                    foreach (string i in arr)
                    {
                        Model_PostCustomItem cpi_2 = new Model_PostCustomItem();
                        cpi_2.PCDID       = (int)CustomGroup.HomeGroup;
                        cpi_2.PostID      = intPostID;
                        cpi_2.PcGroupName = "HomeGroup";
                        cpi_2.MID         = !string.IsNullOrEmpty(Request.Form["b3_id_" + i]) ? int.Parse(Request.Form["b3_id_" + i]) : 0;
                        cpi_2.Caption1    = Request.Form["caption_s_" + i];
                        cpi_2.URL         = Request.Form["b3_url_" + i];
                        cpi_2.PcName      = "banner-client";
                        cpi_2.Insert(cpi_2);
                    }
                }
            }



            if (pctList.SingleOrDefault(i => i.PcGroupName == "ProductGroup") != null)
            {
                //            product_detail = 1,
                //product_information = 2,
                //product_b_announce = 3,
                //product_b_rigth = 4

                //banner announce
                Model_PostCustomItem cpi = new Model_PostCustomItem();
                cpi.PostID      = intPostID;
                cpi.PCDID       = (int)CustomGroup.ProductGroup;
                cpi.PcGroupName = "ProductGroup";
                cpi.MID         = !string.IsNullOrEmpty(p_banner_ann_mid_8.Value) ? int.Parse(p_banner_ann_mid_8.Value) : 0;
                cpi.Caption1    = p_banner_ann_caption.Text.Trim();
                cpi.URL         = p_banner_ann_8.Value;
                cpi.PcName      = "product-b-announce";

                cpi.ClearCustomByPostIDandName(intPostID, "product-b-announce");
                cpi.Insert(cpi);


                //banner left
                Model_PostCustomItem cpi_1 = new Model_PostCustomItem();
                cpi_1.PCDID       = (int)CustomGroup.ProductGroup;
                cpi_1.PostID      = intPostID;
                cpi_1.PcGroupName = "ProductGroup";
                cpi_1.MID         = !string.IsNullOrEmpty(p_banner_mid_9.Value) ? int.Parse(p_banner_mid_9.Value) :0;
                cpi_1.Caption1    = p_banner_rigth.Text.Trim();
                cpi_1.URL         = p_banner_9.Value;
                cpi_1.PcName      = "product-b-rigth";
                cpi_1.ClearCustomByPostIDandName(intPostID, "product-b-rigth");
                cpi_1.Insert(cpi_1);

                //product detail
                Model_PostCustomItem p_detail = new Model_PostCustomItem();
                p_detail.PCDID       = (int)CustomGroup.ProductGroup;
                p_detail.PostID      = intPostID;
                p_detail.PcGroupName = "ProductGroup";
                p_detail.ContentHTML = ProductDetail.Text;
                p_detail.PcName      = "product-detail";
                p_detail.ClearCustomByPostIDandName(intPostID, "product-detail");
                p_detail.Insert(p_detail);

                //product information
                Model_PostCustomItem p_information = new Model_PostCustomItem();
                p_information.PCDID       = (int)CustomGroup.ProductGroup;
                p_information.PostID      = intPostID;
                p_information.PcGroupName = "ProductGroup";
                p_information.ContentHTML = ProductInformation.Text;
                p_information.PcName      = "product-information";
                p_information.ClearCustomByPostIDandName(intPostID, "product-information");
                p_information.Insert(p_information);



                //Product Code
                Model_PostCustomItem cpi_code = new Model_PostCustomItem();
                cpi_code.PCDID       = (int)CustomGroup.ProductGroup;
                cpi_code.PostID      = intPostID;
                cpi_code.PcGroupName = "ProductGroup";
                cpi_code.TextData    = txtProductCode.Text;
                cpi_code.PcName      = "product-code";
                cpi_code.ClearCustomByPostIDandName(intPostID, "product-code");
                cpi_code.Insert(cpi_code);

                //Product Quantity
                Model_PostCustomItem cpi_quan = new Model_PostCustomItem();
                cpi_quan.PCDID       = (int)CustomGroup.ProductGroup;
                cpi_quan.PostID      = intPostID;
                cpi_quan.PcGroupName = "ProductGroup";
                cpi_quan.NumData     = string.IsNullOrEmpty(txtProductQuantity.Text)? 0: int.Parse(txtProductQuantity.Text);
                cpi_quan.PcName      = "product-quantity";
                cpi_quan.ClearCustomByPostIDandName(intPostID, "product-quantity");
                cpi_quan.Insert(cpi_quan);

                //Product Code
                //Model_PostCustomItem cpi_price = new Model_PostCustomItem();
                //cpi_price.PCDID = (int)CustomGroup.ProductGroup;
                //cpi_price.PostID = intPostID;
                //cpi_price.PcGroupName = "ProductGroup";
                //cpi_price.PriceData = string.IsNullOrEmpty(txtProductPrice.Text) ? 0 : decimal.Parse(txtProductPrice.Text);
                //cpi_price.PcName = "product-price-per-unit";
                //cpi_price.ClearCustomByPostIDandName(intPostID, "product-price-per-unit");
                //cpi_price.Insert(cpi_price);


                //            product_code = 5,
                //product_quantity = 6,
                //product_price_per_unit = 7
            }


            //Model_PostCustomGroup pct = new Model_PostCustomGroup();
            //List<Model_PostCustomGroup> pctList = pct.getCustomByPostID(intPostID);

            //foreach (Model_PostCustomGroup pci in pctList)
            //{
            //    switch (pci.PcGroupName)
            //    {
            //        case "HomeGroup":
            //            pn_home_custom.Visible = true;



            //            break;
            //    }
            //}product_tax_cat product_tax_tags
            Model_TaxMap ctm              = new Model_TaxMap();
            string       product_tax_cat  = Request.Form["product_tax_cat"];
            string       product_tax_tags = Request.Form["product_tax_tags"];

            if (!string.IsNullOrEmpty(product_tax_cat))
            {
                ctm.ClearRaxPostMap(intPostID, (byte)PostTaxonomyType.Categories);

                string[] arrcat = product_tax_cat.Split(',');
                foreach (string i in arrcat)
                {
                    ctm.UpdateInsertPostTax(int.Parse(i), intPostID, (byte)PostTaxonomyType.Categories);
                }
            }
            if (!string.IsNullOrEmpty(product_tax_tags))
            {
                ctm.ClearRaxPostMap(intPostID, (byte)PostTaxonomyType.Tags);
                string[] arrtag = product_tax_tags.Split(',');
                foreach (string i in arrtag)
                {
                    ctm.UpdateInsertPostTax(int.Parse(i), intPostID, (byte)PostTaxonomyType.Tags);
                }
            }


            string gall = Request.Form["checkGall"];
            if (!string.IsNullOrEmpty(gall))
            {
                Model_PostMedia pm = new Model_PostMedia
                {
                    PostMediaTypeID = PostMediaType.Gallery,
                    PostID          = intPostID
                };
                pm.DeletePostMedia(pm);
                string[] arrGall = gall.Split(',');
                foreach (string i in arrGall)
                {
                    Model_PostMedia cpm = new Model_PostMedia
                    {
                        PostMediaTypeID = PostMediaType.Gallery,
                        PostID          = intPostID,
                        MID             = int.Parse(i),
                        Priority        = int.Parse(Request.Form["p_gall_pri" + i])
                    };
                    cpm.insertMediaPostGall(cpm);
                }
            }
            else
            {
                Model_PostMedia pm = new Model_PostMedia
                {
                    PostMediaTypeID = PostMediaType.Gallery,
                    PostID          = intPostID
                };
                pm.DeletePostMedia(pm);
            }

            //Media Gallery


            if (p.UpdatePost(p))
            {
                Response.Redirect(Request.Url.ToString());
            }
        }
    }
示例#16
0
    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 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);
    }
    public static List <Model_Post> GetPostArchive(byte PostTypeID)
    {
        Model_Post post = new Model_Post();

        return(post.GetPostArchiveByPostType(PostTypeID));
    }
    public static Model_Post GetPostSlug(string Slug, PostType postType)
    {
        Model_Post post = new Model_Post();

        return(post.GetPostBySlug(Slug, postType));
    }