public void TestPerfAddOrder(List <IOrderModel> buyOrders, List <IOrderModel> sellOrders, IDemoExchangeDbContextFactory <OrderContext> orderContextFactory) { int i = 0; using OrderContext buy = orderContextFactory.Create(); foreach (IOrderModel request in buyOrders) { OrderBL order = new OrderBL(request.AccountId, request.Action, request.Ticker, request.Type, request.Quantity, request.OrderPrice, request.TimeInForce); buy.Orders.Add((OrderEntity)order); BuyBook.TestPerfAddOrderNoSort(order); if ((i % 1000) == 0) { buy.SaveChanges(); } } buy.SaveChanges(); BuyBook.TestPerfSort(); i = 0; using OrderContext sell = orderContextFactory.Create(); foreach (IOrderModel request in sellOrders) { OrderBL order = new OrderBL(request.AccountId, request.Action, request.Ticker, request.Type, request.Quantity, request.OrderPrice, request.TimeInForce); sell.Orders.Add((OrderEntity)order); SellBook.TestPerfAddOrderNoSort(order); if ((i % 1000) == 0) { sell.SaveChanges(); } } sell.SaveChanges(); SellBook.TestPerfSort(); }
public IOrderModel GetOrder(String orderId) { using OrderContext context = orderContextFactory.Create(); OrderEntity entity = context.Orders.Find(Guid.Parse(orderId)); return((entity == null) ? null : new OrderBL(entity)); }
public List <IAccountModel> List() { Logger.Here().Information("BGN"); using AccountContext context = accountContextFactory.Create(); List <AccountEntity> data = context.Accounts.ToList(); List <IAccountModel> response = new List <IAccountModel>(); data.ForEach(account => response.Add(new AccountBL(account))); Logger.Here().Information("END"); return(response); }
public async Task <ActionResult <Order> > GetOrder(String orderId) { logger.Information("GetOrder: " + orderId); // TODO: Authorization: User is admin or creator of the order using OrderContext context = orderContextFactory.Create(); OrderEntity entity = null; try { entity = await context.Orders.FindAsync(Guid.Parse(orderId)); } catch (Exception e) { logger.Warning("GetOrder: " + orderId + " Exception: " + e.Message); return(BadRequest()); } if (entity == null) { logger.Warning("GetOrder: " + orderId + " not found"); return(BadRequest()); } return(Ok(OrderTransformer.ToOrder(entity))); }