コード例 #1
0
        public string CancelCoupon([FromBody] string inPut)
        {
            KaKaoCouponResultModel model = new KaKaoCouponResultModel();

            string result = DataBase.ExecuteNonQuery(inPut, this.ActionContext.Request.RequestUri.ToString());

            if (result == "99")
            {
                model.code = "200";
                model.msg  = "사용취소 되었습니다.";
            }
            else if (result == "-1")
            {
                model.code = "-201";
                model.msg  = "쿠폰번호가 존재하지 않습니다.";
            }
            else if (result == "-2")
            {
                model.code = "-202";
                model.msg  = "사용하지 않은 쿠폰은 취소처리 할 수 없습니다.";
            }
            else if (result == "-3")
            {
                model.code = "-203";
                model.msg  = "이미 취소처리된 쿠폰입니다.";
            }
            else if (result == "-4")
            {
                model.code = "-204";
                model.msg  = "구입하지 않은 쿠폰입니다.";
            }

            return(JsonConvert.SerializeObject(model, Formatting.Indented));
        }
コード例 #2
0
        public string CreateCoupon([FromBody] string inPut)
        {
            int iCouponCnt = 0;
            KaKaoCouponResultModel model      = new KaKaoCouponResultModel();
            List <string>          listCoupon = new List <string>();

            //호출한 파라미터가 숫자형인지 체크한다.
            if (int.TryParse(inPut, out iCouponCnt) == false)
            {
                model.code = "-200";
                model.msg  = string.Format("{0}", "형변환 오류가 있습니다.");

                return(JsonConvert.SerializeObject(model, Formatting.Indented));
            }

            //요청온 갯수만큼 쿠폰번호를 생성한다.
            for (int i = 0; i < iCouponCnt; i++)
            {
                listCoupon.Add(Common.CommonExtension.RandomString(6));
            }

            if (listCoupon.Count > 0)
            {
                string result = DataBase.ExecuteNonQuery(listCoupon, this.ActionContext.Request.RequestUri.ToString());

                model.code = "200";
                model.msg  = string.Format("{0} (요청건: {1} 발급건: {2})", "쿠폰 생성이 완료되었습니다.", inPut.ToString(), result);
            }
            else
            {
                model.code = "-201";
                model.msg  = "생성 할 쿠폰이 없습니다.";
            }

            return(JsonConvert.SerializeObject(model, Formatting.Indented));
        }