Ejemplo n.º 1
0
        public void BookBookingOrder(BookingOrder bookingOrder)
        {
            var marketProduct = GetMarketProduct(bookingOrder.MarketProduct.ProductCode);

            if (marketProduct.Price <= bookingOrder.Threshold)
            {
                var trader = GetTraderById(bookingOrder.Trader.Id);
                context.Traders.Update(trader);
                context.Market.Update(marketProduct);

                var depotTransaction = new DepotTransaction(trader, marketProduct, bookingOrder.Amount);

                var bankTransaction = new BankTransaction(trader, -depotTransaction.Total, depotTransaction.ReasonString); //TODO: Verwendungszweck
                BookBankTransaction(bankTransaction);

                var depotPosition = trader.Depot.GetPosition(marketProduct.Product);
                depotPosition.Amount += depotTransaction.Amount;

                context.SaveChanges();
            }
        }
Ejemplo n.º 2
0
        public static void SeedDemoData(IPandaRepository pandaRepo)
        {
            var products = pandaRepo.GetAllProducts();

            if (!products.Any())
            {
                pandaRepo.AddMarketProduct(new MarketProduct("LAX"));
                pandaRepo.IncreaseMarketProductAmount("LAX", 100);
                pandaRepo.SetMarketProductPrice("LAX", 25.50m);

                pandaRepo.AddMarketProduct(new MarketProduct("ISI"));
                pandaRepo.IncreaseMarketProductAmount("ISI", 1000);
                pandaRepo.SetMarketProductPrice("ISI", 3.99m);

                pandaRepo.AddMarketProduct(new MarketProduct("WOT"));
                pandaRepo.IncreaseMarketProductAmount("WOT", 200);
                pandaRepo.SetMarketProductPrice("WOT", 1234567.89m);
            }

            var traders = pandaRepo.GetAllTraders();

            if (!traders.Any())
            {
                pandaRepo.AddNewTrader("WBuffett");
                pandaRepo.AddNewTrader("JBelfort");
                var jb = pandaRepo.GetTraderByName("JBelfort");
                var bt = new BankTransaction(jb, 20000.0m);
                pandaRepo.BookBankTransaction(bt);

                var lax = pandaRepo.GetMarketProduct("LAX");
                var bo  = new BookingOrder(jb, lax, 4, 30.0m);
                pandaRepo.PlaceBookingOrder(bo);

                var unbookdBo = pandaRepo.GetBookingOrdersUnbooked();

                pandaRepo.BookBookingOrder(bo);
            }
        }
Ejemplo n.º 3
0
 public void PlaceBookingOrder(BookingOrder bookingOrder)
 {
     context.BookingOrders.Add(bookingOrder);
     context.SaveChanges();
 }