コード例 #1
0
        public async Task <JObject> ValidateUtilityRecharge(string rechargetype, string operatorName, string consumer_number, string customer_mobile)
        {
            JObject     json = null;
            RechargeAPI api  = new RechargeAPI();

            try
            {
                api = await this.FetchValidationApiDetails(rechargetype, operatorName);

                api.ApiValue = FormUtilityValidtaionAPIString(api.ApiValue, consumer_number, customer_mobile);
                using (var httpClient = new HttpClient())
                {
                    httpClient.DefaultRequestHeaders.Add("User-Agent", "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36");
                    var response = httpClient.GetStringAsync(new Uri(api.ApiValue)).Result;
                    json = JObject.Parse(response);
                    // var releases = JArray.Parse(response);
                }
                return(json);
            }
            catch (Exception ex)
            {
                JObject errorJson = JObject.Parse(ex.Message);
                return(errorJson);
            }
        }
コード例 #2
0
        public async Task <List <RechargeAPI> > GetRechargeAPI(string rechargeMode)
        {
            List <RechargeAPI> apiList = new List <RechargeAPI>();

            using (SqlConnection connection = new SqlConnection(this._connectionString))
            {
                connection.Open();
                using (SqlCommand command = new SqlCommand("GET_RECHARGE_API_INFO_BY_MODE", connection))
                {
                    command.CommandType = CommandType.StoredProcedure;
                    command.Parameters.Add("@rechargeMode", SqlDbType.VarChar, 50).Value = rechargeMode.ToUpper();
                    try
                    {
                        using (SqlDataReader reader = await command.ExecuteReaderAsync())
                        {
                            while (reader.Read())
                            {
                                var api = new RechargeAPI
                                {
                                    RechargeMode = reader["rechargeMode"].ToString(),
                                    OperatorName = reader["operatorName"].ToString(),
                                    ApiValue     = reader["apiValue"].ToString()
                                };
                                apiList.Add(api);
                            }
                        }
                        return(apiList);
                    }
                    catch (Exception ex)
                    {
                        return(null);
                    }
                }
            }
        }
コード例 #3
0
        public bool recharge(long userID, long money)
        {
            var  u        = db.User.SingleOrDefault(x => x.ID == userID);
            var  taikhoan = db.UserBank.SingleOrDefault(x => x.UserID == userID);
            bool res      = new RechargeAPI().Recharge(money, taikhoan.STK, taikhoan.Pass);

            if (res)
            {
                u.Balance += money;
                db.SaveChanges();
                return(true);
            }
            return(false);
        }
コード例 #4
0
        public async Task <RechargeAPI> FetchValidationApiDetails(string rechargeMode, string operatorName)
        {
            RechargeAPI api = null;

            using (SqlConnection connection = new SqlConnection(this._connectionString))
            {
                connection.Open();
                using (SqlCommand command = new SqlCommand("FETCH_API_VALIDATION_STATUS", connection))
                {
                    command.CommandType = CommandType.StoredProcedure;
                    command.Parameters.Add("@rechargeMode", SqlDbType.VarChar, 50).Value = rechargeMode;
                    command.Parameters.Add("@operatorName", SqlDbType.VarChar, 50).Value = operatorName;
                    try
                    {
                        using (SqlDataReader reader = await command.ExecuteReaderAsync())
                        {
                            while (reader.Read())
                            {
                                api = new RechargeAPI
                                {
                                    RechargeMode = reader["rechargeMode"].ToString(),
                                    OperatorName = reader["operatorName"].ToString(),
                                    ApiValue     = reader["validationApiValue"].ToString()
                                };
                                break;
                            }
                        }
                        return(api);
                    }
                    catch (Exception ex)
                    {
                        return(null);
                    }
                }
            }
        }
コード例 #5
0
 public async Task <bool> UpdateRechargeAPIValidation([FromBody] RechargeAPI api)
 {
     return(await this.rs.UpdateValidationApiDetails(api.RechargeMode, api.OperatorName, api.ApiValue));
 }
コード例 #6
0
 public async Task <bool> SaveRechargeAPI([FromBody] RechargeAPI api)
 {
     return(await this.rs.SaveRechargeAPI(api.RechargeMode, api.OperatorName, api.ApiValue));
 }