Exemple #1
0
 public int Ins(Languages aLanguages)
 {
     try {
         _aDatabaseDa.Languages.AddOrUpdate(aLanguages);
         return _aDatabaseDa.SaveChanges();
     }
     catch (Exception ex) {
         throw new Exception(String.Format("LanguagesBO.Ins: {0}", ex.Message));
     }
 }
        private void Ins(HttpContext context)
        {
            LanguagesBO languagesBO = new LanguagesBO();
            String jSonString = "";
            try {
                Languages aLanguages = new Languages();

                aLanguages.NameLang = !String.IsNullOrEmpty(context.Request.Form["txtNameLang"])
                    ? Convert.ToString(context.Request.Form["txtNameLang"])
                    : aLanguages.NameLang;
                aLanguages.Image = !String.IsNullOrEmpty(context.Request.Form["txtImage_1"])
                    ? Convert.ToString(context.Request.Form["txtImage_1"])
                    : aLanguages.Image;
                aLanguages.Directory = !String.IsNullOrEmpty(context.Request.Form["txtDirectory"])
                    ? Convert.ToString(context.Request.Form["txtDirectory"])
                    : aLanguages.Directory;
                aLanguages.Filename = !String.IsNullOrEmpty(context.Request.Form["txtFilename"])
                    ? Convert.ToString(context.Request.Form["txtFilename"])
                    : aLanguages.Filename;
                aLanguages.Status = !String.IsNullOrEmpty(context.Request.Form["cbbStatus"])
                    ? Convert.ToInt32(context.Request.Form["cbbStatus"])
                    : aLanguages.Status;
                aLanguages.Type = !String.IsNullOrEmpty(context.Request.Form["cbbType"])
                    ? Convert.ToInt32(context.Request.Form["cbbType"])
                    : aLanguages.Type;
                aLanguages.Disable = !String.IsNullOrEmpty(context.Request.Form["cbbDisable"])
                    ? Convert.ToBoolean(context.Request.Form["cbbDisable"])
                    : aLanguages.Disable;

                int ret = languagesBO.Ins(aLanguages);

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