示例#1
0
 public int Ins(Albums aAlbums)
 {
     try {
         databaseDA.Albums.AddOrUpdate(aAlbums);
         return databaseDA.SaveChanges();
     }
     catch (Exception ex) {
         throw new Exception(String.Format("AlbumsBO.Ins: {0}", ex.Message));
     }
 }
示例#2
0
        private void Ins(HttpContext context, int NUM_LANG)
        {
            int ret = -1;
            String jSonString = "";
            try {
                long a = DateTime.Now.Ticks;
                TimeSpan Codespan = new TimeSpan(a);
                AlbumsBO albumsBO = new AlbumsBO();
                for (int i = 1; i <= NUM_LANG; i++) {
                    Albums aAlbums = new Albums();
                    aAlbums.Code = Math.Floor(Codespan.TotalSeconds).ToString();
                    aAlbums.Status = !String.IsNullOrEmpty(context.Request.Form["cbbStatus"])
                        ? Convert.ToInt32(context.Request.Form["cbbStatus"])
                        : 1;

                    aAlbums.Disable = !String.IsNullOrEmpty(context.Request.Form["cbbDisable"])
                        ? Convert.ToBoolean(context.Request.Form["cbbDisable"])
                        : false;

                    aAlbums.CreateDate = DateTime.Now;

                    aAlbums.CreateByIDUser = currentSystemUsers.ID;
                    aAlbums.Image = !String.IsNullOrEmpty(context.Request.Form["txtImage_1"])
                        ? Convert.ToString(context.Request.Form["txtImage_1"])
                        : "";

                    aAlbums.Image1 = !String.IsNullOrEmpty(context.Request.Form["txtImage_2"])
                        ? Convert.ToString(context.Request.Form["txtImage_2"])
                        : "";
                    aAlbums.Image2 = !String.IsNullOrEmpty(context.Request.Form["txtImage_3"])
                        ? Convert.ToString(context.Request.Form["txtImage_3"])
                        : "";
                    aAlbums.Image3 = !String.IsNullOrEmpty(context.Request.Form["txtImage_4"])
                        ? Convert.ToString(context.Request.Form["txtImage_4"])
                        : "";

                    aAlbums.Type = !String.IsNullOrEmpty(context.Request.Form["cbbType"])
                        ? Convert.ToInt32(context.Request.Form["cbbType"])
                        : 0;

                    aAlbums.ViewCount = !String.IsNullOrEmpty(context.Request.Form["txtViewCount"])
                        ? Convert.ToInt64(context.Request.Form["txtViewCount"])
                        : 0;
                    aAlbums.DownloadCount = !String.IsNullOrEmpty(context.Request.Form["txtViewdowload"])
                        ? Convert.ToInt64(context.Request.Form["txtViewdowload"])
                        : 0;

                    aAlbums.IDLang = !String.IsNullOrEmpty(context.Request.Form["IDLang_" + i])
                        ? Convert.ToInt32(context.Request.Form["IDLang_" + i])
                        : 0;

                    aAlbums.Title = !String.IsNullOrEmpty(context.Request.Form["txtTitle_Lang" + i])
                        ? Convert.ToString(context.Request.Form["txtTitle_Lang" + i])
                        : "";

                    aAlbums.Info = !String.IsNullOrEmpty(context.Request.Form["txtInfo_Lang" + i])
                        ? Convert.ToString(HttpUtility.HtmlDecode(context.Request.Form["txtInfo_Lang" + i]))
                        : "";

                    aAlbums.Intro = !String.IsNullOrEmpty(context.Request.Form["txtIntro_Lang" + i])
                        ? Convert.ToString(context.Request.Form["txtIntro_Lang" + i])
                        : "";

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