public static cg_cms_Pages_Info getCmsPageByName(string pageName, string IetfLanguageTag)
        {
            caval_goEntities db = new caval_goEntities();

            if (IetfLanguageTag == null) IetfLanguageTag = System.Threading.Thread.CurrentThread.CurrentCulture.IetfLanguageTag;

            var pageInfo = (from ppg in db.cg_cms_Pages
                            where ppg.Name.ToLower() == pageName.ToLower()
                            from l in db.cg_Languages
                            where l.SystemLocale.ToLower() == IetfLanguageTag.ToLower()
                            from pi in ppg.cg_cms_Pages_Info
                            where pi.LanguageId == l.LanguageId
                            select pi).FirstOrDefault();

            if (pageInfo == null)
            {
                var defaultCulture = ConfigurationManager.AppSettings["defaultLocale"];
                System.Globalization.CultureInfo cultureInfo = new System.Globalization.CultureInfo(defaultCulture);

                pageInfo = (from ppg in db.cg_cms_Pages
                            where ppg.Name.ToLower() == pageName.ToLower()
                            from l in db.cg_Languages
                            where l.SystemLocale.ToLower() == cultureInfo.IetfLanguageTag.ToLower()
                            from pi in ppg.cg_cms_Pages_Info
                            where pi.LanguageId == l.LanguageId
                            select pi).FirstOrDefault();
            }

            if (pageInfo == null) pageInfo = new cg_cms_Pages_Info();

            return pageInfo;
        }
 /// <summary>
 /// Deprecated Method for adding a new object to the cg_cms_Pages_Info EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddTocg_cms_Pages_Info(cg_cms_Pages_Info cg_cms_Pages_Info)
 {
     base.AddObject("cg_cms_Pages_Info", cg_cms_Pages_Info);
 }
 /// <summary>
 /// Create a new cg_cms_Pages_Info object.
 /// </summary>
 /// <param name="cmsPageInfoId">Initial value of the CmsPageInfoId property.</param>
 /// <param name="cmsPageId">Initial value of the CmsPageId property.</param>
 /// <param name="languageId">Initial value of the LanguageId property.</param>
 public static cg_cms_Pages_Info Createcg_cms_Pages_Info(global::System.Int64 cmsPageInfoId, global::System.Int64 cmsPageId, global::System.Int64 languageId)
 {
     cg_cms_Pages_Info cg_cms_Pages_Info = new cg_cms_Pages_Info();
     cg_cms_Pages_Info.CmsPageInfoId = cmsPageInfoId;
     cg_cms_Pages_Info.CmsPageId = cmsPageId;
     cg_cms_Pages_Info.LanguageId = languageId;
     return cg_cms_Pages_Info;
 }
        public ActionResult cms_page_info_add(FormCollection collection)
        {
            long pageId = Convert.ToInt64(collection["PageId"]);
            cg_cms_Pages item = db.cg_cms_Pages.Where(p => p.PageId == pageId).FirstOrDefault();

            cg_cms_Pages_Info itemInfo = new cg_cms_Pages_Info();

            // add values
            itemInfo.Name = collection["pageName"];
            itemInfo.Code = collection["Code"];
            itemInfo.Tag_Description = collection["Tag_Description"];
            itemInfo.Tag_Keywords = collection["Tag_Keywords"];
            itemInfo.Tag_Title = collection["Tag_Title"];
            itemInfo.LanguageId = Convert.ToInt64(collection["LanguageId"]);

            // add to DB & save
            item.cg_cms_Pages_Info.Add(itemInfo);
            db.SaveChanges();

            return RedirectToAction("cms_page_infos", new { id = pageId });
        }