public void SetValue(ExtendProperties aExtendProperties )
 {
     this.ID = aExtendProperties.ID;
     this.Name = aExtendProperties.Name;
     this.Value = aExtendProperties.Value;
     this.ValueType = aExtendProperties.ValueType;
     this.Image = aExtendProperties.Image;
     this.Code = aExtendProperties.Code;
     this.IDObject = aExtendProperties.IDObject;
     this.ObjectType = aExtendProperties.ObjectType;
     this.IDLang = aExtendProperties.IDLang;
     this.Type = aExtendProperties.Type;
     this.Group = aExtendProperties.Group;
     this.Status = aExtendProperties.Status;
     this.CodeObject = aExtendProperties.CodeObject;
     this.Disable = aExtendProperties.Disable;
 }
 public ExtendProperties ConvertToExtendProperties()
 {
     ExtendProperties aExtendProperties = new ExtendProperties();
       aExtendProperties.ID=this.ID ;
      aExtendProperties.Name= this.Name;
      aExtendProperties.Value = this.Value; ;
      aExtendProperties.ValueType=this.ValueType;
      aExtendProperties.Image=this.Image;
      aExtendProperties.Code=this.Code;
      aExtendProperties.IDObject=this.IDObject;
      aExtendProperties.ObjectType=this.ObjectType;
      aExtendProperties.IDLang=this.IDLang;
     aExtendProperties.Type=this.Type;
     aExtendProperties.Group=this.Group;
     aExtendProperties.Status=this.Status;
     aExtendProperties.CodeObject=this.CodeObject;
     aExtendProperties.Disable=this.Disable;
     return aExtendProperties;
 }
 // by object
 public int Upd(ExtendProperties aExtendProperties)
 {
     try
     {
         aDatabaseDA.ExtendProperties.AddOrUpdate(aExtendProperties);
         return aDatabaseDA.SaveChanges();
     }
     catch (Exception ex)
     {
         throw new Exception(String.Format("ExtendPropertiesBO.Upd: {0}", ex.Message));
     }
 }
        public void Ins(HttpContext context, int NUM_LANG)
        {
            ConfigsBO aConfigsBO = new ConfigsBO();

            //CodeCategoryLevel1 = Convert.ToString(context.Request.Form["txtCodeCategoryLevel1"]);

            String jSonString = "";
            try
            {
                List<ExtendProperties> aListExtendProperties = new List<ExtendProperties>();

                ExtendPropertiesBO aExtendPropertiesBO = new ExtendPropertiesBO();
                ExtendProperties aExtendProperties = new ExtendProperties();
                TimeSpan Codespan = new TimeSpan(DateTime.Now.Ticks);
                string Code = Math.Floor(Codespan.TotalSeconds).ToString();

                for (int i = 1; i <= NUM_LANG; i++)
                {
                    aExtendProperties = new ExtendProperties();
                    aExtendProperties.Code = Code;
                    //aContents.Data = null;
                    aExtendProperties.Name = !String.IsNullOrEmpty(context.Request.Form["txtName"]) ? Convert.ToString(context.Request.Form["txtName"]) : "";
                    aExtendProperties.Value = !String.IsNullOrEmpty(context.Request.Form["txtValue"]) ? Convert.ToString(context.Request.Form["txtValue"]) : "";
                    aExtendProperties.ValueType = !String.IsNullOrEmpty(context.Request.Form["cbbValueType"]) ? Convert.ToInt32(context.Request.Form["cbbValueType"]) : 0;
                    aExtendProperties.Image = !String.IsNullOrEmpty(context.Request.Form["txtImage"]) ? Convert.ToString(context.Request.Form["txtImage"]) : "";
                    aExtendProperties.Code = Code;
                    aExtendProperties.IDObject = !String.IsNullOrEmpty(context.Request.Form["cbbIDObject"]) ? Convert.ToInt32(context.Request.Form["cbbIDObject"]) : 0;
                    aExtendProperties.ObjectType = !String.IsNullOrEmpty(context.Request.Form["cbbObjectType"]) ? Convert.ToInt32(context.Request.Form["cbbObjectType"]) : 0;
                    aExtendProperties.IDLang = !String.IsNullOrEmpty(context.Request.Form["IDLang_" + i]) ? Convert.ToInt32(context.Request.Form["IDLang_" + i]) : 0;
                    aExtendProperties.Type = !String.IsNullOrEmpty(context.Request.Form["cbbType"]) ? Convert.ToInt32(context.Request.Form["cbbType"]) : 0;
                    aExtendProperties.Group = !String.IsNullOrEmpty(context.Request.Form["cbbGroup"]) ? Convert.ToInt32(context.Request.Form["cbbGroup"]) : 0;
                    aExtendProperties.Status = !String.IsNullOrEmpty(context.Request.Form["cbbStatus"]) ? Convert.ToInt32(context.Request.Form["cbbStatus"]) : 0;
                    aExtendProperties.CodeObject = !String.IsNullOrEmpty(context.Request.Form["cbbCodeObject"]) ? Convert.ToInt32(context.Request.Form["cbbCodeObject"]) : 0;

                    //aContents.CreatedBy = aCurrentSystemUsers.Username;

                    aExtendProperties.Disable = !String.IsNullOrEmpty(context.Request.Form["cbbDisable"]) ? Convert.ToBoolean(context.Request.Form["cbbDisable"]) : false;
                    //aContents.Tag = !String.IsNullOrEmpty(context.Request.Form["txtTag"]) ? Convert.ToString(context.Request.Form["txtTag"]) : "";
                    //aContents.DateCreated = !String.IsNullOrEmpty(context.Request.FormCodeObjecttxtDateCreated"]) ? DateTime.ParseExact(context.Request.Form["txtDateCreated"], "dd/MM/yyyy", culture) : DateTime.Now;

                    //aContents.DateEdited = !String.IsNullOrEmpty(context.Request.Form["txtDateEdited"]) ? DateTime.ParseExact(context.Request.Form["txtDateEdited"], "dd/MM/yyyy", culture) : DateTime.Now;
                    //aContents.UpdateBy = !String.IsNullOrEmpty(context.Request.Form["txtUpdateBy"]) ? Convert.ToString(context.Request.Form["txtUpdateBy"]) : "";
                    //aContents.PublishDate = !String.IsNullOrEmpty(context.Request.Form["txtPublishDate"]) ? DateTime.ParseExact(context.Request.Form["txtPublishDate"], "dd/MM/yyyy", culture) : DateTime.Now;

                    //aContents.ExpireDate = !String.IsNullOrEmpty(context.Request.Form["txtExpireDate"]) ? DateTime.ParseExact(context.Request.Form["txtExpireDate"], "dd/MM/yyyy", culture) : DateTime.Now;
                    //aContents.IDAlbum = !String.IsNullOrEmpty(context.Request.Form["txtIDAlbum"]) ? Convert.ToInt32(context.Request.Form["txtIDAlbum"]) : 0;
                    //aContents.ViewCount = !String.IsNullOrEmpty(context.Request.Form["txtViewCount"]) ? Convert.ToInt64(context.Request.Form["txtViewCount"]) : 0;

                    aExtendProperties.Image = !String.IsNullOrEmpty(context.Request.Form["txtImage"]) ? Convert.ToString(context.Request.Form["txtImage"]) : "";
                    //aContents.Image2 = !String.IsNullOrEmpty(context.Request.Form["txtImage_3"]) ? Convert.ToString(context.Request.Form["txtImage_3"]) : "";
                    //aContents.Image3 = !String.IsNullOrEmpty(context.Request.Form["txtImage_4"]) ? Convert.ToString(context.Request.Form["txtImage_4"]) : "";

                    //aContents.Title = !String.IsNullOrEmpty(context.Request.Form["txtTitle_Lang" + i]) ? Convert.ToString(context.Request.Form["txtTitle_Lang" + i]) : "";
                    //aContents.Intro = !String.IsNullOrEmpty(context.Request.Form["txtIntro_Lang" + i]) ? Convert.ToString(HttpUtility.HtmlDecode(context.Request.Form["txtIntro_Lang" + i])) : "";
                    //aContents.Info = !String.IsNullOrEmpty(context.Request.Form["txtInfo_Lang" + i]) ? Convert.ToString(HttpUtility.HtmlDecode(context.Request.Form["txtInfo_Lang" + i])) : "";

                    //aContents.ExtendProperties1 = !String.IsNullOrEmpty(context.Request.Form["txtExtendProperties1_Lang" + i]) ? Convert.ToString(context.Request.Form["txtExtendProperties1_Lang" + i]) : "";
                    //aContents.ExtendProperties2 = !String.IsNullOrEmpty(context.Request.Form["txtExtendProperties2_Lang" + i]) ? Convert.ToString(context.Request.Form["txtExtendProperties2_Lang" + i]) : "";
                    //aContents.ExtendProperties3 = !String.IsNullOrEmpty(context.Request.Form["txtExtendProperties3_Lang" + i]) ? Convert.ToString(context.Request.Form["txtExtendProperties3_Lang" + i]) : "";

                    //aContents.Image = !String.IsNullOrEmpty(context.Request.Form["txtImage_1"]) ? Convert.ToString(context.Request.Form["txtImage_1"]) : "";

                    aListExtendProperties.Add(aExtendProperties);
                }

                int Ret1 = -1;
                Ret1 = aExtendPropertiesBO.Ins(ref aListExtendProperties);
                //if (Ret1 < aListExtendProperties.Count)
                //{
                //    jSonString = "{\"status\":\"error\" ,\"message\":\"" + Ret1.ToString() + "\"}";
                //     aExtendPropertiesBO.Del(aListExtendProperties);
                //    return;
                //}
                //else
                //{
                //    string ListTempt = !String.IsNullOrEmpty(context.Request.Form["ckbCodeCategoryLevel1[]"]) ? Convert.ToString(context.Request.Form["ckbCodeCategoryLevel1[]"]) : "";
                //    if (string.IsNullOrEmpty(ListTempt) == true)
                //    {
                //        CategoryLevel1BO aCategoryLevel1BO = new CategoryLevel1BO();
                //        List<CategoryLevel1> aListItem = aCategoryLevel1BO.Sel_ByCode("000");
                //        if (aListItem.Count > 0)
                //        {
                //            ListTempt = aListItem[0].Code;
                //        }
                //        else
                //        {
                //            this.CreateCategoryLevel1Default(context, "[Default]", NUM_LANG);
                //            ListTempt = "000";
                //        }
                //    }

                //    //else if (string.IsNullOrEmpty(ListTempt) == false)
                //    //{
                //    List<string> ListCodeCategoryLevel1 = ListTempt.Split(',').ToList();
                //    List<Contents_CategoryLevel1> aListContents_CategoryLevel1 = new List<Contents_CategoryLevel1>();
                //    Contents_CategoryLevel1 aContents_CategoryLevel1 = new Contents_CategoryLevel1();

                //    for (int ii = 0; ii < aListContents.Count; ii++)
                //    {
                //        for (int iii = 0; iii < ListCodeCategoryLevel1.Count; iii++)
                //        {
                //            aContents_CategoryLevel1 = new Contents_CategoryLevel1();

                //            aContents_CategoryLevel1.CodeCategoryLevel1 = ListCodeCategoryLevel1[iii].ToString();
                //            aContents_CategoryLevel1.CodeContents = aListContents[ii].Code.ToString();
                //            aContents_CategoryLevel1.Disable = aListContents[ii].Disable;
                //            aContents_CategoryLevel1.IDLang = aListContents[ii].IDLang;
                //            aContents_CategoryLevel1.Status = aListContents[ii].Status;
                //            aContents_CategoryLevel1.Type = aListContents[ii].Type;

                //            aListContents_CategoryLevel1.Add(aContents_CategoryLevel1);
                //        }
                //    }
                //    Contents_CategoryLevel1BO aContents_CategoryLevel1BO = new Contents_CategoryLevel1BO();
                //    int Ret2 = -1;
                //    Ret2 = aContents_CategoryLevel1BO.Ins(ref aListContents_CategoryLevel1);
                //    if (Ret2 < aListContents_CategoryLevel1.Count)
                //    {
                //        aContents_CategoryLevel1BO.Del(aListContents_CategoryLevel1);
                //        aContentsBO.Del(aListContents);
                //        jSonString = "{\"status\":\"error\" ,\"message\":\"" + Ret2.ToString() + "\"}";
                //        return;
                //    }
                //    //}
                //}

                jSonString = "{\"status\": \"success\"}";
            }
            catch (Exception ex)
            {
                jSonString = "{\"status\":\"error\" ,\"message\":\"" + ex.Message.ToString() + "\"}";
            }
            finally
            {
                context.Response.Write(jSonString);
            }
        }