コード例 #1
0
ファイル: AlbumsAction.cs プロジェクト: califaxit/manhquang
        private void Sel_ByCode(HttpContext context)
        {
            String   jSonString = string.Empty;
            AlbumsBO albumsBO   = new AlbumsBO();

            String code = Convert.ToString(context.Request.QueryString["Code"]);

            bool disable = !String.IsNullOrEmpty(context.Request.QueryString["Disable"])
                ? Convert.ToBoolean(context.Request.QueryString["Disable"])
                : false;

            List <Albums> listAlbums =
                String.IsNullOrEmpty(Convert.ToString(context.Request.QueryString["Disable"]))
                    ? albumsBO.Sel_ByCode(code)
                    : albumsBO.Sel_ByCode(code, disable);

            if (listAlbums.Any())
            {
                _converter.DateTimeFormat = "dd/MM/yyyy";
                jSonString = JsonConvert.SerializeObject(listAlbums, _converter);
            }

            jSonString = "{\"data\":" + jSonString + "}";
            context.Response.Write(jSonString);
        }
コード例 #2
0
ファイル: AlbumsAction.cs プロジェクト: califaxit/manhquang
        private void Upd_ByCode(HttpContext context, int NUM_LANG)
        {
            int    ret        = -1;
            string jSonString = string.Empty;

            try {
                if (NUM_LANG < 1)
                {
                    NUM_LANG = 1;
                }
                AlbumsBO      albumsBO   = new AlbumsBO();
                String        Code       = context.Request.Form["txtCode"];
                List <Albums> listAlbums = albumsBO.Sel_ByCode(Code);

                if (listAlbums.Count <= NUM_LANG)
                {
                    int LoopUpdate = listAlbums.Count;
                    for (int i = 0; i < LoopUpdate; i++)
                    {
                        listAlbums[i].ID = listAlbums[i].ID;

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

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

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

                        listAlbums[i].Status = !String.IsNullOrEmpty(context.Request.Form["cbbStatus"])
                            ? Convert.ToInt32(context.Request.Form["cbbStatus"])
                            : listAlbums[i].Status;

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

                        listAlbums[i].CreateDate = !String.IsNullOrEmpty(context.Request.Form["dtpPublishDate"])
                            ? DateTime.ParseExact(context.Request.Form["dtpPublishDate"], "dd/MM/yyyy", _culture)
                            : listAlbums[i].CreateDate;

                        listAlbums[i].CreateByIDUser = currentSystemUsers.ID;

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

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

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

                        listAlbums[i].IDLang = !String.IsNullOrEmpty(context.Request.Form["IDLang_" + (i + 1)])
                            ? Convert.ToInt32(context.Request.Form["IDLang_" + (i + 1)])
                            : listAlbums[i].IDLang;
                        listAlbums[i].ViewCount = !String.IsNullOrEmpty(context.Request.Form["txtViewCount"])
                            ? Convert.ToInt64(context.Request.Form["txtViewCount"])
                            : listAlbums[i].ViewCount;
                        listAlbums[i].DownloadCount = !String.IsNullOrEmpty(context.Request.Form["txtDownloadCount"])
                            ? Convert.ToInt64(context.Request.Form["txtDownloadCount"])
                            : listAlbums[i].DownloadCount;

                        ret = albumsBO.Upd_Albums(listAlbums[i]);
                        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);
            }
        }