public ActionResult Test(String id) { RECHARGE WC = new RECHARGE("*****@*****.**", "Web@123", "http://dmtsrv.appsmith.co.in/"); object postdata = new { country_code = "IN", operator_code = 1, number = id, amount = 10, requestid = "C1B78C983B0E46A", reqvia = "API", recharge_type = 0, optionalparam = string.Empty, optionalparam1 = string.Empty, }; RECHARGERESPONSE RR = WC.ProcessRecharge(postdata, "Recharge"); if (RR.results.Count > 0) { // getting first item from recharge result object which got from websmith api RECHARGERESPONSERESULT _result = RR.results[0]; if (_result.status_code == 3) { // update fail code here to neej recharge database. } } return(View()); }
internal void ProcessRecharge(string _number, int _operatorcode, int _amounttorecharge, string _requestid, int _rechargetype) { object postdata = new { country_code = "IN", operator_code = _operatorcode, number = _number, amount = _amounttorecharge, requestid = _requestid, reqvia = "API", recharge_type = _rechargetype, optionalparam = string.Empty, optionalparam1 = string.Empty, }; try { RECHARGE WC = new RECHARGE("*****@*****.**", "Bansi@123", "http://dmtsrv.appsmith.co.in/"); // add log or response here. new BAL.Log().Insert(new ENT.Log() { logdata = new JavaScriptSerializer().Serialize(postdata), CreatedDateTime = DateTime.Now, type = COM.MyEnumration.LOGTYPE.APIREQ, title = "PROCESS - WEBSMITH API" }); RECHARGERESPONSE RR = WC.ProcessRecharge(postdata, "Recharge"); // add log or response here. new BAL.Log().Insert(new ENT.Log() { logdata = new JavaScriptSerializer().Serialize(RR), CreatedDateTime = DateTime.Now, type = COM.MyEnumration.LOGTYPE.APIRES, title = "PROCESS - WEBSMITH API" }); if (RR.results.Count > 0) { // getting first item from recharge result object which got from websmith api RECHARGERESPONSERESULT _result = RR.results[0]; if (_result.status_code == 3) { // update fail code here to local database. new BAL.Recharge().UpdateRecharge(_requestid, _result.transNo == null ? string.Empty : _result.transNo, 3, new JavaScriptSerializer().Serialize(_result)); } else if (_result.status_code == 4) { // update success code here to local database. new BAL.Recharge().UpdateRecharge( _requestid, _result.transNo == null ? string.Empty : _result.transNo, 4, new JavaScriptSerializer().Serialize(_result)); } } } catch (Exception ex) { ERRORREPORTING.Report(ex, Request.Url.ToString(), _LoginUserId, _ERRORKEY, new JavaScriptSerializer().Serialize(postdata)); } }