예제 #1
0
        public bool Insert(Domain.Stock stock)
        {
            using (FhQuotesContext ctx = new FhQuotesContext())
            {
                if (ctx.Stocks.Find(stock.Symbol) == null)
                {
                    ctx.Stocks.Add(stock.ToEF());
                    ctx.SaveChanges();
                    return(true);
                }

                return(false);
            }
        }
예제 #2
0
        public bool Insert(string stockSymbol, Domain.Quote quote)
        {
            using (FhQuotesContext ctx = new FhQuotesContext())
            {
                Stock stock = ctx.Stocks.Find(stockSymbol);
                if (stock == null)
                {
                    return(false);
                }

                var quoteEF = quote.ToEF();
                quoteEF.Stock = stock;
                ctx.Quotes.Add(quoteEF);
                ctx.SaveChanges();

                return(true);
            }
        }