Exemple #1
0
        public double GetCurrentQuote(string username)
        {
            if (ServerDB.UsernameExists(username))
            {
                return(QUOTE);
            }

            return(0.0);
        }
Exemple #2
0
        static void Tests()
        {
            // Initialize the quote
            ServerDB.InitQuote(10);

            // Update Quote
            ServerDB.UpdateQuote(5);

            if (ServerDB.GetQuote() != 5)
            {
                Console.WriteLine("Test Failed");
            }

            ServerDB.UpdateQuote(10);

            if (ServerDB.GetQuote() != 10)
            {
                Console.WriteLine("Test Failed");
            }

            // Register Users
            ServerDB.Register("uDavid", "David", "pass1");
            ServerDB.Register("uEdu", "Edu", "pass2");
            ServerDB.Register("uEdu", "x", "pass2");
            ServerDB.Register("uEdu", "Edu", "x");

            // Login
            if (ServerDB.Login("uEdu", "pass2") != "Edu")
            {
                Console.WriteLine("Test Failed");
            }

            if (ServerDB.Login("x", "pass2") != null)
            {
                Console.WriteLine("Test Failed");
            }

            if (ServerDB.Login("uEdu", "x") != null)
            {
                Console.WriteLine("Test Failed");
            }

            // Order
            List <int> diginotes = new List <int>();

            diginotes = ServerDB.InsertPurchaseOrder("uEdu", 6);
            diginotes = ServerDB.InsertSellingOrder("uDavid", 2);
            diginotes = ServerDB.InsertSellingOrder("uDavid", 2);
            diginotes = ServerDB.InsertSellingOrder("uDavid", 2);

            diginotes = ServerDB.InsertSellingOrder("uEdu", 6);
            diginotes = ServerDB.InsertPurchaseOrder("uDavid", 2);
            diginotes = ServerDB.InsertPurchaseOrder("uDavid", 2);
            diginotes = ServerDB.InsertPurchaseOrder("uDavid", 2);
        }
Exemple #3
0
        public DiginoteSystem()
        {
            if (!ServerDB.InitQuote(QUOTE))
            {
                QUOTE = ServerDB.GetQuote();
            }

            ServerDB.NewDBTransaction += HandleNewDBTransactionHandler;

            Console.WriteLine("Starting System with quote: " + QUOTE);
            Console.WriteLine("DiginoteSystem constructor called.");
        }
Exemple #4
0
 public List <SellOrder> GetPendingSellOrders(string username)
 {
     return(ServerDB.GetSellingOrders(username));
 }
Exemple #5
0
 public List <Diginote> GetDiginotes(string username)
 {
     return(ServerDB.GetDiginotes(username));
 }
Exemple #6
0
 public List <int> SellOrders(string username, int quantity)
 {
     return(ServerDB.InsertSellingOrder(username, quantity));
 }
Exemple #7
0
 public List <int> PurchaseOrders(string username, int quantity)
 {
     return(ServerDB.InsertPurchaseOrder(username, quantity));
 }
Exemple #8
0
 public string Login(string username, string password)
 {
     return(ServerDB.Login(username, password));
 }
Exemple #9
0
 public string Register(string username, string nickname, string password)
 {
     return(ServerDB.Register(username, nickname, password));
 }
Exemple #10
0
 // Setter for the static value of QUOTE that triggers the event
 private void SetQuote(double value)
 {
     QUOTE = value;
     ServerDB.UpdateQuote(QUOTE);
     UpdateQuote.Invoke(QUOTE);
 }
Exemple #11
0
 public void UnsuspendOrders(string username)
 {
     ServerDB.UnsuspendOrders(username);
 }
Exemple #12
0
 public void DeletePurchaseOrder(PurchaseOrder order)
 {
     ServerDB.DeletePurchaseOrder(order);
 }
Exemple #13
0
 public void DeleteSellOrder(SellOrder order)
 {
     ServerDB.DeleteSellingOrder(order);
 }
Exemple #14
0
 public List <Transaction> GetRecentTransactions()
 {
     return(ServerDB.GetTransactions(25));
 }
Exemple #15
0
 public List <Transaction> GetTransactions(string username)
 {
     return(ServerDB.GetTransactions(username));
 }
Exemple #16
0
 public List <PurchaseOrder> GetPendingPurchaseOrders(string username)
 {
     return(ServerDB.GetPurchaseOrders(username));
 }