public JsonResult GenerationToDB() { Stopwatch sw = Stopwatch.StartNew(); List <Vendors> VendorsWithProducts = gen.GenerateVendorsAndProductsDB(QtyVendors, ProductsFromOneVendor); if (db.Vendors.Count() > 0) { db.Database.ExecuteSqlCommand("DELETE FROM [Vendors]"); } db.Vendors.AddRange(VendorsWithProducts); try { db.SaveChanges(); } catch (Exception) { // Обработать исключения } sw.Stop(); return(Json(sw.Elapsed.ToString())); }
public const double additionalCosts = 30; // cents/KWh public CompareController(CompareContext context) { _context = context; if (_context.ProductItems.Count() == 0) { // Create new ProductItems _context.ProductItems.Add(new ProductItem { Type = ProductType.Basic }); _context.ProductItems.Add(new ProductItem { Type = ProductType.Packaged }); _context.SaveChanges(); } }