예제 #1
0
        public BankHelper GetBalance(string user)
        {
            BankHelper balance = null;

            try
            {
                using (var reader = _Connection.QueryReader("SELECT * FROM Bank WHERE User = @0", user))
                {
                    if (reader.Read())
                    {
                        balance = new BankHelper()
                        {
                            User = reader.Get<string>("User"),
                            Amount = reader.Get<int>("Amount")
                        };
                    }
                    else
                    {
                        _Connection.Query("INSERT INTO Bank (User, Amount) VALUES (@0, 0)", user);

                        balance = new BankHelper()
                        {
                            User = user,
                            Amount = 0
                        };
                    }
                }
            }
            catch (Exception ex)
            {
                ExtendedLog.Current.Log(ex.ToString());
            }

            return balance;
        }
예제 #2
0
        public BankHelper GetBalance(string user)
        {
            BankHelper balance = null;

            try
            {
                using (var reader = _Connection.QueryReader("SELECT * FROM Bank WHERE User = @0", user))
                {
                    if (reader.Read())
                    {
                        balance = new BankHelper()
                        {
                            User   = reader.Get <string>("User"),
                            Amount = reader.Get <int>("Amount")
                        };
                    }
                    else
                    {
                        _Connection.Query("INSERT INTO Bank (User, Amount) VALUES (@0, 0)", user);

                        balance = new BankHelper()
                        {
                            User   = user,
                            Amount = 0
                        };
                    }
                }
            }
            catch (Exception ex)
            {
                ExtendedLog.Current.Log(ex.ToString());
            }

            return(balance);
        }