public IActionResult GetAQuoteInSQL(QuoteViewModel model) { var watch = Stopwatch.StartNew(); var Quote = new Quote() { FirstName = model.FirstName, LastName = model.LastName, Email = model.Email, PostCode = model.PostCode, Created = DateTime.Now }; string quoteNumber = RandomString(8); Quote.QuoteNumber = quoteNumber; _context.Quotes.Add(Quote); _context.SaveChanges(); var firstCompany = (from c in _context.Quotes select c).FirstOrDefault(); var kvp = firstCompany.Id; watch.Stop(); var elapsedMs = watch.ElapsedMilliseconds; if (ModelState.IsValid) { ViewBag.Message = "Quote number is: " + quoteNumber + " Time taken: " + elapsedMs + "ms"; } return View(); }
public void EnsureSeedData() { if(!_quoteContext.Quotes.Any()) { var quote = new Quote() { FirstName = "Ashwini", LastName = "Laxminarayana", PostCode = "NR13NS", Email = "*****@*****.**" }; _quoteContext.Quotes.Add(quote); _quoteContext.SaveChanges(); } }