示例#1
0
        public async Task <List <WithDrawal> > GetWithDrawals(string accountnumber)
        {
            try
            {
                List <WithDrawal> withDrawals = null;
                using (var con = await DataConnection.Connection())
                {
                    var cmd = DataConnection.Command(con, "sp_GetLastWithDrawals", CommandType.StoredProcedure);
                    cmd.Parameters.AddWithValue("@Accountnumber", accountnumber);
                    SqlDataReader sdr = await cmd.ExecuteReaderAsync();

                    if (sdr.HasRows)
                    {
                        withDrawals = new List <WithDrawal>();
                        while (await sdr.ReadAsync())
                        {
                            WithDrawal obj = new WithDrawal();
                            obj.Amount        = double.Parse(sdr["Amount"].ToString());
                            obj.Description   = sdr["Description"].ToString();
                            obj.ExecutionDate = Convert.ToDateTime(sdr["ExecutionDate"]);
                            withDrawals.Add(obj);
                        }
                    }
                }
                return(withDrawals);
            }
            catch (Exception)
            {
                throw;
            }
        }
示例#2
0
        /// <summary>
        /// 提币
        /// </summary>
        /// <param name="withDraw">提币信息</param>
        /// <returns></returns>
        public async Task <JObject> makeWithDrawalAsync(WithDrawal withDraw)
        {
            var url     = $"{this.BASEURL}{this.ACCOUNT_SEGMENT}/withdrawal";
            var bodyStr = JsonConvert.SerializeObject(withDraw);

            using (var client = new HttpClient(new HttpInterceptor(this._apiKey, this._secret, this._passPhrase, bodyStr)))
            {
                var res = await client.PostAsync(url, new StringContent(bodyStr, Encoding.UTF8, "application/json"));

                var contentStr = await res.Content.ReadAsStringAsync();

                return(JObject.Parse(contentStr));
            }
        }
 public async Task <IActionResult> MakeWithDrawal(WithDrawal obj)
 {
     try
     {
         GetAtributes(obj);
         Accounts acc = _accountRepository.GetAccount(obj.AccountNumber);
         if (acc == null)
         {
             return(DisplayError("Not Successful", "This Account Not Exist"));
         }
         if (await _transactionRepository.Insert(obj) != null)
         {
             return(RedirectToAction("ConfirmTransaction"));
         }
         return(DisplayError("Not Successful", "Something went wrong"));
     }
     catch (Exception ex)
     {
         return(DisplayError("Not Successful", ex.Message));
     }
 }
 public async Task <ActionResult <WithDrawal> > Insert(WithDrawal obj)
 {
     try
     {
         int value = 0;
         using (var con = await DataConnection.Connection())
         {
             var cmd = DataConnection.Command(con, "sp_MakeWithDrawal", CommandType.StoredProcedure);
             cmd.Parameters.AddWithValue("@FullName", obj.FullName);
             cmd.Parameters.AddWithValue("@ClientID", obj.ClientID);
             cmd.Parameters.AddWithValue("@ExecutionDate", obj.ExecutionDate);
             cmd.Parameters.AddWithValue("@Description", obj.Description);
             cmd.Parameters.AddWithValue("@CardNumber", obj.CardNumber);
             cmd.Parameters.AddWithValue("@AccountNumber", obj.AccountNumber);
             cmd.Parameters.AddWithValue("@Amount", obj.Amount);
             value = await DataConnection.GetValue(cmd);
         }
         return(await DataConnection.Result(value, obj));
     }
     catch (Exception)
     {
         throw;
     }
 }