public IEnumerable <CommodityPrice> GetCommodityPrices() { using (var context = new InfoExchangeContext()) { return(context.CommodityPrices.ToArray()); } }
public IEnumerable <User> GetUsers() { using (var context = new InfoExchangeContext()) { return(context.Users.ToArray()); } }
public Commodity GetCommodity(Guid commodityID) { using (var context = new InfoExchangeContext()) { return(context.Commodities.Find(commodityID)); } }
public void UpadateAskLeg(AskLeg leg) { using (var context = new InfoExchangeContext()) { UpadateAskLeg(leg); } }
private void UpdateAskLeg(AskLeg leg, InfoExchangeContext context) { leg.Ask = null; context.AskLegs.Attach(leg); context.Entry(leg).State = EntityState.Modified; context.SaveChanges(); }
public void UpdateAsk(Ask ask) { using (var context = new InfoExchangeContext()) { UpdateAsk(ask, context); } }
public void AddAsk(Ask ask) { using (var context = new InfoExchangeContext()) { SubmitAsk(ask, context); } }
public IEnumerable <Ask> GetAsks() { using (var context = new InfoExchangeContext()) { return(context.Asks.AsNoTracking().Include(a => a.CommodityBuy).Include(a => a.CommoditySell).Include(a => a.AskLegs).Where( a => (a.ValidToDate == null || a.ValidToDate >= DateTime.UtcNow) && (a.BuyQuantity > 0 || a.SellQuantity > 0)).ToArray()); } }
public IEnumerable <Ask> GetAsks(int commodityID) { using (var context = new InfoExchangeContext()) { return(context.Asks.AsNoTracking().Include(a => a.CommodityBuy).Include(a => a.CommoditySell).Where( a => a.CommodityBuyID == commodityID || a.CommoditySellID == commodityID).ToArray()); } }
private void UpdateAsk(Ask ask, InfoExchangeContext context) { ask.CommodityBuy = null; ask.CommoditySell = null; ask.User = null; ask.AskLegs = null; context.Asks.Attach(ask); context.Entry(ask).State = EntityState.Modified; context.SaveChanges(); }
private void DeleteAsk(Ask ask, InfoExchangeContext context) { var dAsk = context.Asks.Find(ask.AskID); if (dAsk != null) { context.Asks.Remove(dAsk); context.SaveChanges(); } }
private void SaveOrder(Order order, InfoExchangeContext context) { if (order.OrderID == Guid.Empty) { order.OrderID = Guid.NewGuid(); } order.OrderDate = DateTime.UtcNow; foreach (var leg in order.OrderLegs) { leg.OrderID = order.OrderID; if (leg.OrderLegID == Guid.Empty) { leg.OrderLegID = Guid.NewGuid(); } context.OrderLegs.Add(leg); } context.Orders.Add(order); context.SaveChanges(); }
public void ExecuteAsk(Ask ask, IEnumerable <Order> orders, IEnumerable <Ask> orderLegAsks, IEnumerable <AskLeg> askLegs) { using (var context = new InfoExchangeContext()) { using (var scope = new TransactionScope()) { AsksToUpdate.Enqueue(ask); foreach (var order in orders) { SaveOrder(order, context); if (orderLegAsks != null) { foreach (var orderAsk in orderLegAsks) { AsksToUpdate.Enqueue(orderAsk); } } } scope.Complete(); } } }
private void SubmitAsk(Ask ask, InfoExchangeContext context) { ask.AskDate = DateTime.UtcNow; context.Asks.Add(ask); context.SaveChanges(); }