public JsonResult AjaxSubmitCoupon() { string dataString = Request.Form["Data"]; dataString = HttpUtility.UrlDecode(dataString); Coupon info = ECommerce.Utility.SerializationUtility.JsonDeserialize2 <Coupon>(dataString); SetBizEntityUserInfo(info, info.SysNo.HasValue ? false : true); UserAuthVM user = UserAuthHelper.GetCurrentUser(); if (user == null) { throw new ECommerce.Utility.BusinessException(); } info.Status = CouponStatus.WaitingAudit; info.MerchantSysNo = user.SellerSysNo; info.EditUser = user.UserID; info.InUser = user.UserID; if (info.SysNo.HasValue && info.SysNo > 0) { info = CouponService.Update(info); } else { info = CouponService.Create(info); } return(Json(new { Data = info })); }
public async Task <ActionResult> Create(CouponVM c) { if (ModelState.IsValid) { // check if only one of the possible options has been selected if (!c.IsOnlyOneOptionSelected) { ModelState.AddModelError(string.Empty, "Only one of the options should be selected"); await PopulateSelectLists(); return(View(c)); } var uniqueId = GenerateUniqueId(); while (await _cs.UniqueIdExisting(uniqueId)) { uniqueId = GenerateUniqueId(); } c.UniqueId = uniqueId; c.SiteUserId = UserData.UserId; c.Img = await GenerateImage(uniqueId, c.Expires, c.Discount); c = await _cs.Create(c); return(RedirectToAction("Index", new { createdId = c.CouponId })); } await PopulateSelectLists(); return(View(c)); }
public void _002_TestCouponCreate() { var ServiceObject = new CouponService(); var ArgsObject = new CouponCreateServiceOptions(); ArgsObject.coupon_code = time; ArgsObject.date_expire = "2099-12-22"; ArgsObject.type = "shipping"; var result = ServiceObject.Create(ArgsObject); coupon_code = result.coupon_code; Assert.IsInstanceOf<TwoCheckoutResponse>(result); }
public void _002_TestCouponCreate() { var ServiceObject = new CouponService(); var ArgsObject = new CouponCreateServiceOptions(); ArgsObject.coupon_code = time; ArgsObject.date_expire = "2099-12-22"; ArgsObject.type = "shipping"; var result = ServiceObject.Create(ArgsObject); coupon_code = result.coupon_code; Assert.IsInstanceOf <TwoCheckoutResponse>(result); }
public IActionResult Create([FromBody] Coupon coupon) { var reader = new StreamReader(Request.Body); Console.WriteLine("Request body"); Console.WriteLine(reader.ReadToEnd()); Console.WriteLine(Newtonsoft.Json.JsonConvert.SerializeObject(coupon)); if (TryUpdateModelAsync(coupon).Result) { Console.WriteLine("update model success"); } else { Console.WriteLine(string.Join("\n", ModelState.Select(x => x.Key + ":" + x.Value.Errors.First().ErrorMessage))); } if (!ModelState.IsValid) { return(BadRequest(new { status = "error", errorCode = ErrorCodes.InvalidCouponData, message = "Invalid coupon data posted" })); } service.Create(coupon); return(new ObjectResult(new { status = "success", data = coupon, location = "/api/coupon/" + coupon.Id })); }
private static Coupon GetCoupon(Order order) { Coupon coupon = null; if (order.DiscountId.HasValue && order.Discount > 0) { var couponCode = order.DiscountCoupon; if (couponCode.IsNullEmptyOrWhiteSpace()) { couponCode = "COUPON_" + order.DiscountId; } //create a coupon var options = new CouponCreateOptions { Duration = "once", Id = couponCode, AmountOff = (long)order.Discount }; var service = new CouponService(); coupon = service.Create(options); } return(coupon); }
private static bool ActualSmsSend(string mobilenumber, string message, string Gateway, EcouponCampaignDTO EcouponCampaignDTO, ClientDTO ClientDTO, string CouponCode) { string result = ""; bool IsSent = false; int SMSMsgCount = GetMessageCount(message); message = MsgCorrect(message); if (message != "" && mobilenumber != "")// Check for empty message. { string Url = ConfigurationManager.AppSettings["TransactionalGateWay"].ToString(); Url = Url.Replace("%26", "&"); Url = Url.Replace("[recipient]", mobilenumber); Url = Url.Replace("[message]", message); if (Gateway != "022751") //if (Gateway.ToLower() != "default") { Url = Url.Replace("[gateway]", Gateway); //Gateway = "MSGBLS" } else { Url = ""; Url = ConfigurationManager.AppSettings["PromotionalGateWay"].ToString(); Url = Url.Replace("%26", "&"); Url = Url.Replace("[recipient]", mobilenumber); Url = Url.Replace("[message]", message); } HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(Url); myRequest.Method = "GET"; WebResponse myResponse = myRequest.GetResponse(); StreamReader sr = new StreamReader(myResponse.GetResponseStream(), System.Text.Encoding.UTF8); result = sr.ReadToEnd(); sr.Close(); string statuscode = ""; if (result.Contains('|')) { statuscode = result.Substring(0, result.IndexOf('|')); } else { statuscode = result; } string SMSReplyMessage = SMSResult(statuscode) + "-" + result; //result myResponse.Close(); if (statuscode == "1701") { IsSent = true; CouponDTO CouponDTO = new CouponDTO(); //CouponDTO.IsSuccess = true; CouponDTO.EcouponCampaignId = EcouponCampaignDTO.Id; CouponDTO.MobileNumber = mobilenumber; CouponDTO.Code = CouponCode; CouponDTO.IsRedeem = false; CouponDTO.MessageId = result; SettingDTO SettingDTO = new SettingDTO(); SettingDTO = SettingService.GetById(1); double ActualSMSMsgCount = SettingDTO.NationalCouponSMSCount * SMSMsgCount; CouponDTO.MessageCount = SMSMsgCount; CouponDTO.RequiredCredits = ActualSMSMsgCount; CouponDTO.Message = message; //CouponDTO.MessageStatus = SMSReplyMessage; //CouponDTO.GatewayID = Gateway; CouponDTO.SentDateTime = System.DateTime.Now; CouponDTO.IsCouponSent = true; //CouponDTO.MessageID = statuscode; //if (statuscode == "1701") //{ // CampaignLogDTO.IsSuccess = true; //} //else if (statuscode != "1701") //{ // CampaignLogDTO.IsSuccess = false; //} CouponService.Create(CouponDTO); //// Reduce SMS Credits From Client //ClientDTO.SMSCredit = ClientDTO.SMSCredit - ActualSMSMsgCount; // SMSMsgCount; //ClientService.Edit(ClientDTO); } } return(IsSent);// result; }