private Money GetTestMoney() { Money money = new Money(); money.id = "026908d67bc249fcb542fa2c4786c1b65"; money.value = 5; money.signature = "NscaJHrr6XndK4PD8SDwnb5UYr5IpDF/W7U3BCB6aEz+zSNYEU2co932Q024DCiYMjqeS3e0odDuOid0qouI9yiu5kzUKuYgzRDXBHFX3jpBWC8c05XzG7PDc99H9K3imJ4eBWvRl4mMAD9zyTSiSNQHYrkYiMg7tAGW7l/2DNU="; money.dated = "10/23/2015 2:07:35 PM"; money.ownerId = "india/mh/pune/kharadi/6bef105a11ee406a8189404653d0895f-1"; return money; }
public void Store(Money money) { string spName = "sp_OldMoney_Insert"; try { SqlCommand cmd = new SqlCommand(spName, CON); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@Id", money.id); cmd.Parameters.AddWithValue("@Value", money.value); cmd.Parameters.AddWithValue("@OwnerId", money.ownerId); CON.Open(); cmd.ExecuteNonQuery(); } catch (Exception e) { throw new Exception("Error while connecting database", e); } finally { if (CON != null)CON.Close(); } //store in Db }
public bool CheckPreviousMoneyEntry(Money money) { bool result = false; SqlCommand cmd = new SqlCommand(); cmd.CommandText = "SELECT 1 FROM " + APKSTORE_TABLE_NAME + " WHERE [Id] = '" + money.id +"'"; cmd.Connection = CON; CON.Open(); using (var reader = cmd.ExecuteReader()) { if(reader.Read()) if (reader.HasRows) result= true; } CON.Close(); return result; }
public List<ServiceData.Money> GetMoneyFromUserAccount(string userAddressId, string uid) { List<ServiceData.Money> moneyList = new List<ServiceData.Money>(); ServiceData.Money money; CON = new SqlConnection(CONNECTION_STR); SqlCommand cmd = new SqlCommand(); cmd.CommandText = "SELECT * FROM " + USER_AC_TABLE + " WHERE UserId = " + uid + " AND Status = " + 0; cmd.Connection = CON; CON.Open(); try { using (var reader = cmd.ExecuteReader()) { int value; while (reader.Read()) { money = new ServiceData.Money(); money.id = reader["Id"].ToString(); int.TryParse(reader["Value"].ToString(), out value); money.value = value; money.hash = reader["Hash"].ToString(); money.ownerId = reader["OwnerId"].ToString(); money.dated = reader["Dated"].ToString(); money.signature = Convert.ToBase64String((byte[])reader["Signature"]); moneyList.Add(money); } } } catch (Exception e) { throw new Exception("DB Exception :" + e.InnerException); } finally { CON.Close(); } return moneyList; }