예제 #1
0
 public async Task <ICreditCard> updateCreditCard(ICreditCard cc)
 {
     using (var conn = new SQLiteConnection(_connectionString))
     {
         conn.Open();
         var sqlstr = @"UPDATE Creditcard set created = " + cc.GetCreated() +
                      "lastused = " + cc.GetLastUsed() +
                      "pin = " + cc.GetPinCode() +
                      "wrongpincodeattemps = " + cc.GetWrongPinCodeAttemps() +
                      "account = " + cc.GetAccount().GetId() +
                      "blocked = " + cc.IsBlocked() +
                      "WHERE id = " + cc.GetId() + ";";
         var command = new SQLiteCommand(sqlstr, conn);
         await command.ExecuteNonQueryAsync();
     }
     return(cc);
 }
예제 #2
0
 public async Task <ICreditCard> createCreditCard(ICreditCard cc)
 {
     using (var conn = new SQLiteConnection(_connectionString)){
         conn.Open();
         //newly created CCs with 0 wrongpinattemps and not blocked
         var sqlstr = @"INSERT INTO Creditcard (created, lastused, pin, wrongpincodeattemps, account, blocked) 
                     VALUES ('" + cc.GetCreated().ToLongDateString() + "','" + cc.GetLastUsed().ToLongDateString() + "'," + cc.GetPinCode() + ", 0," + cc.GetAccount().GetId() + ", 0);";
         System.Console.WriteLine(sqlstr);
         var command = new SQLiteCommand(sqlstr, conn);
         await command.ExecuteNonQueryAsync();
     }
     return(cc);
 }
예제 #3
0
        public void getPin_emptyValue_returns0()
        {
            var actual = cc.GetPinCode();

            Assert.That(actual, Is.EqualTo(0));
        }