/// <summary> /// get data child for insert update /// </summary> /// <param name="contdescObj"></param> /// <returns></returns> private PNK_ContentStaticDesc GetDataObjectChild(PNK_ContentStaticDesc productcatdescObj, int lang) { switch (lang) { case 1: productcatdescObj.MainId = this.productcategoryId; productcatdescObj.LangId = Constant.DB.LangId; //string str = SanitizeHtml.Sanitize(txtName.Value); productcatdescObj.Title = SanitizeHtml.Sanitize(txtName.Value); productcatdescObj.Brief = txtIntro.Text; productcatdescObj.Detail = editBriefVi.Text; break; case 2: productcatdescObj.MainId = this.productcategoryId; productcatdescObj.LangId = Constant.DB.LangId_En; productcatdescObj.Title = string.IsNullOrEmpty(txtNameEng.Value) ? SanitizeHtml.Sanitize(txtName.Value) : SanitizeHtml.Sanitize(txtNameEng.Value); productcatdescObj.Brief = string.IsNullOrEmpty(txtIntroEn.Text) ? txtIntro.Text : txtIntroEn.Text; productcatdescObj.Detail = string.IsNullOrEmpty(editBriefEn.Text) ? editBriefVi.Text : editBriefEn.Text; break; } return(productcatdescObj); }
/// <summary> /// Save location /// </summary> private void SaveContentStaticCategory() { //Xoá cache trước khi lưu CacheHelper.ClearContains("ContentStatic"); PNK_ContentStatic productcatObj = new PNK_ContentStatic(); PNK_ContentStaticDesc productcatObjVn = new PNK_ContentStaticDesc(); PNK_ContentStaticDesc productcatObjEn = new PNK_ContentStaticDesc(); if (this.productcategoryId == int.MinValue) { //get data insert productcatObj = this.GetDataObjectParent(productcatObj); productcatObj.PostDate = DateTime.Now; productcatObj.Ordering = genericBLL.getOrdering(); productcatObjVn = this.GetDataObjectChild(productcatObjVn, Constant.DB.LangId); productcatObjEn = this.GetDataObjectChild(productcatObjEn, Constant.DB.LangId_En); List <PNK_ContentStaticDesc> lst = new List <PNK_ContentStaticDesc>(); lst.Add(productcatObjVn); lst.Add(productcatObjEn); //excute this.productcategoryId = generic2CBLL.Insert(productcatObj, lst); } else { string[] fields = { "Id" }; productcatObj.Id = this.productcategoryId; productcatObj = genericBLL.Load(productcatObj, fields); //string publisheddOld = productcatObj.Published; //get data update productcatObj = this.GetDataObjectParent(productcatObj); productcatObjVn = this.GetDataObjectChild(productcatObjVn, Constant.DB.LangId); productcatObjEn = this.GetDataObjectChild(productcatObjEn, Constant.DB.LangId_En); List <PNK_ContentStaticDesc> lst = new List <PNK_ContentStaticDesc>(); lst.Add(productcatObjVn); lst.Add(productcatObjEn); //excute generic2CBLL.Update(productcatObj, lst, fields); //neu ve Published oo thay doi thi chay ham ChangeWithTransaction de doi Published cac con va cac product //if (publisheddOld != productcatObj.Published) // PNK_ContentStatic.ChangeWithTransaction(DBConvert.ParseString(this.productcategoryId), productcatObj.Published); } }