Exemplo n.º 1
0
        static void DatabaseTest()
        {
            IDataService <User> svc = new GenericDataService <User>(new EF.SimpleTraderDbContextFactory());

            Console.WriteLine(svc.Create(new User
            {
                Username = "******",
                Email    = "*****@*****.**",
                //Password = "******",
                DateJoined = DateTime.Now
            }
                                         ));

            Console.WriteLine(svc.Create(new User
            {
                Username = "******",
                Email    = "*****@*****.**",
                //Password = "******",
                DateJoined = DateTime.Now
            }
                                         ));

            //GET ONE
            Console.WriteLine(svc.GetOne(1).Result);
            //GET ALL
            Console.WriteLine(svc.GetAll().Result);
            //UPDATE
            //REMOVE
            Console.ReadKey();
        }
Exemplo n.º 2
0
        static void BuyStockTest()
        {
            IStockService          stockPriceService = new StockService();
            IDataService <Account> accountService    = new GenericDataService <Account>(new EF.SimpleTraderDbContextFactory());
            IBuyStockService       buyStockService   = new BuyStockService(stockPriceService, accountService);

            Account account = accountService.GetOne(1).Result;

            // x账户 买 AAPL 股票 2份
            buyStockService.BuyStock(account, "AAPL", 2);
        }