Esempio n. 1
0
        public IActionResult UpdateVouchAddon([FromBody] B2dVoucherAddon vouch_addon)
        {
            Dictionary <string, object> jsonData = new Dictionary <string, object>();

            try
            {
                var vouchRepos = HttpContext.RequestServices.GetService <VouchAddonRepository>();
                var upd_user   = User.FindFirst("Account").Value;

                var aesUserData = User.FindFirst(ClaimTypes.UserData).Value;
                var UserData    = JsonConvert.DeserializeObject <B2dAccount>(AesCryptHelper.aesDecryptBase64(aesUserData, Website.Instance.AesCryptKey));
                vouch_addon.COMPANY_XID = UserData.COMPANY_XID;

                //更新分銷商公司資料
                vouchRepos.UpdateVouchAddon(vouch_addon, upd_user);
                jsonData["status"] = "OK";
            }
            catch (Exception ex)
            {
                jsonData.Clear();
                jsonData.Add("status", "FAIL");
                jsonData.Add("msg", ex.Message);
            }

            return(Json(jsonData));
        }
Esempio n. 2
0
        // 取得
        public static B2dVoucherAddon GetVoucherAddon(Int64 comp_xid)
        {
            try
            {
                string sqlStmt = @"SELECT * FROM b2b.b2d_voucher_addon
WHERE company_xid=:company_xid";

                NpgsqlParameter[] sqlParams = new NpgsqlParameter[] {
                    new NpgsqlParameter("company_xid", comp_xid)
                };

                var ds = NpgsqlHelper.ExecuteDataset(Website.Instance.SqlConnectionString, CommandType.Text, sqlStmt, sqlParams);

                DataRow dr = ds.Tables[0].Rows[0];

                var vouchAddon = new B2dVoucherAddon()
                {
                    XID          = dr.ToInt64("xid"),
                    COMPANY_XID  = dr.ToInt64("company_xid"),
                    COMPANY_NAME = dr.ToStringEx("company_name"),
                    EMAIL        = dr.ToStringEx("company_email"),
                    LOGO_URL     = dr.ToStringEx("company_logo_url"),
                    TEL          = dr.ToStringEx("company_tel"),
                    ADDRESS      = dr.ToStringEx("company_address")
                };

                return(vouchAddon);
            }
            catch (Exception ex)
            {
                Website.Instance.logger.FatalFormat("{0},{1}", ex.Message, ex.StackTrace);
                throw ex;
            }
        }
Esempio n. 3
0
        // GET: /<controller>/
        public IActionResult Index()
        {
            var services   = HttpContext.RequestServices.GetServices <IB2dAccountRepository>();
            var vouchRepos = HttpContext.RequestServices.GetService <VouchAddonRepository>();

            var aesUserData = User.Identities.SelectMany(i => i.Claims.Where(c => c.Type == ClaimTypes.UserData).Select(c => c.Value)).FirstOrDefault();
            var UserData    = JsonConvert.DeserializeObject <B2dAccount>(AesCryptHelper.aesDecryptBase64(aesUserData, Website.Instance.AesCryptKey));

            B2dVoucherAddon vouch = vouchRepos.GetVoucherAddon(UserData.COMPANY_XID);

            return(View(vouch));
        }
Esempio n. 4
0
        public IActionResult UpdateVouchAddon([FromBody] B2dVoucherAddon vouch_addon)
        {
            Dictionary <string, object> jsonData = new Dictionary <string, object>();

            try
            {
                var vouchRepos = HttpContext.RequestServices.GetService <VouchAddonRepository>();
                var upd_user   = User.FindFirst("Account").Value;

                //更新分銷商公司資料
                vouchRepos.UpdateVouchAddon(vouch_addon, upd_user);
                jsonData["status"] = "OK";
            }
            catch (Exception ex)
            {
                jsonData.Clear();
                jsonData.Add("status", "FAIL");
                jsonData.Add("msg", ex.Message);
            }

            return(Json(jsonData));
        }
Esempio n. 5
0
        public static void UpdateVouchAddon(B2dVoucherAddon addon, string upd_user)
        {
            try
            {
                string sqlStmt = @"UPDATE b2b.b2d_voucher_addon SET company_email=:company_email, company_tel=:company_tel, 
 company_name=:company_name, company_address=:company_address, upd_user=:upd_user, upd_datetime=now()
WHERE company_xid=:company_xid";

                NpgsqlParameter[] sqlParams = new NpgsqlParameter[] {
                    new NpgsqlParameter("company_xid", addon.COMPANY_XID),
                    new NpgsqlParameter("company_email", (object)addon.EMAIL ?? DBNull.Value),
                    new NpgsqlParameter("company_tel", (object)addon.TEL ?? DBNull.Value),
                    new NpgsqlParameter("company_name", (object)addon.COMPANY_NAME ?? DBNull.Value),
                    new NpgsqlParameter("company_address", (object)addon.ADDRESS ?? DBNull.Value),
                    new NpgsqlParameter("upd_user", upd_user)
                };

                NpgsqlHelper.ExecuteNonQuery(Website.Instance.SqlConnectionString, CommandType.Text, sqlStmt, sqlParams);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 6
0
 public void UpdateVouchAddon(B2dVoucherAddon addon, string upd_user)
 {
     VoucherAddonDAL.UpdateVouchAddon(addon, upd_user);
 }