Ejemplo n.º 1
0
 public static Instruments AddInstrument(Instruments instrument)
 {
     using (MarketsEntities context = new MarketsEntities())
     {
         if (instrument.Exchanges != null)
         {
             context.Exchanges.Attach(instrument.Exchanges);
         }
         if (instrument.Markets != null)
         {
             context.Markets.Attach(instrument.Markets);
         }
         //  instruments = context.Instruments.Where(x => x.ExchangeID == exchangeID).Select(y => y).ToList();
         instrument = context.Instruments.Add(instrument);
         context.SaveChanges();
     };
     return(instrument);
 }
Ejemplo n.º 2
0
        public static CurrentData AddCurrentData(CurrentData currentData)
        {
            using (MarketsEntities context = new MarketsEntities())
            {
                if (currentData.Instruments != null)
                {
                    context.Instruments.Attach(currentData.Instruments);
                }
                if (currentData.Markets != null)
                {
                    context.Markets.Attach(currentData.Markets);
                }
                if (currentData.Exchanges != null)
                {
                    context.Exchanges.Attach(currentData.Exchanges);
                }

                currentData = context.CurrentData.Add(currentData);
                context.SaveChanges();
            }
            return(currentData);
        }