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

            return(0.0);
        }
示例#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);
        }
示例#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.");
        }
示例#4
0
 public List <SellOrder> GetPendingSellOrders(string username)
 {
     return(ServerDB.GetSellingOrders(username));
 }
示例#5
0
 public List <Diginote> GetDiginotes(string username)
 {
     return(ServerDB.GetDiginotes(username));
 }
示例#6
0
 public List <int> SellOrders(string username, int quantity)
 {
     return(ServerDB.InsertSellingOrder(username, quantity));
 }
示例#7
0
 public List <int> PurchaseOrders(string username, int quantity)
 {
     return(ServerDB.InsertPurchaseOrder(username, quantity));
 }
示例#8
0
 public string Login(string username, string password)
 {
     return(ServerDB.Login(username, password));
 }
示例#9
0
 public string Register(string username, string nickname, string password)
 {
     return(ServerDB.Register(username, nickname, password));
 }
示例#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);
 }
示例#11
0
 public void UnsuspendOrders(string username)
 {
     ServerDB.UnsuspendOrders(username);
 }
示例#12
0
 public void DeletePurchaseOrder(PurchaseOrder order)
 {
     ServerDB.DeletePurchaseOrder(order);
 }
示例#13
0
 public void DeleteSellOrder(SellOrder order)
 {
     ServerDB.DeleteSellingOrder(order);
 }
示例#14
0
 public List <Transaction> GetRecentTransactions()
 {
     return(ServerDB.GetTransactions(25));
 }
示例#15
0
 public List <Transaction> GetTransactions(string username)
 {
     return(ServerDB.GetTransactions(username));
 }
示例#16
0
 public List <PurchaseOrder> GetPendingPurchaseOrders(string username)
 {
     return(ServerDB.GetPurchaseOrders(username));
 }