Exemple #1
0
        public CalculateQuoteDbModel GetQuoteBy(int key)
        {
            CalculateQuoteDbModel dbResult;

            using (var dbContext = new QuoteDbContext())
            {
                dbResult = dbContext.CalculateQuotes.Find(key);
            }
            return(dbResult);
        }
Exemple #2
0
        public Task SaveQuote(CalculateQuoteDbModel quote)
        {
            var task = new Task(() => {
                using (var dbContext = new QuoteDbContext())
                {
                    dbContext.Database.EnsureDeleted();
                    dbContext.Database.EnsureCreated();
                    dbContext.CalculateQuotes.Add(quote);
                    dbContext.SaveChanges();
                }
            });

            task.Start();

            try
            {
                Task.WaitAll(task);
                return(task);
            }
            catch (AggregateException ex)
            {
                throw ex;
            }
        }