public ActionResult Create([Bind(Include = "Codigo,Nome,Autor,Editora,nExemplares")] livro livro) { if (ModelState.IsValid) { db.Livros.Add(livro); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(livro)); }
/// <summary> /// Quick and dirty simulation of physically isolated databases for tenants /// </summary> /// <param name="settings"></param> private void SeedTestData(TenantSettings settings) { RemoveAllWidgets(); switch (settings.TenantId) { case "tenant1": _context.Widgets.AddRange(new List <Widget>() { new Widget { Id = Guid.NewGuid(), Color = "Yellow", Shape = "Square" }, new Widget { Id = Guid.NewGuid(), Color = "Blue", Shape = "Round" }, }); break; case "tenant2": _context.Widgets.AddRange(new List <Widget>() { new Widget { Id = Guid.NewGuid(), Color = "Green", Shape = "Cube" }, new Widget { Id = Guid.NewGuid(), Color = "Purple", Shape = "Polyhedron" }, }); break; default: _context.Widgets.AddRange(new List <Widget>() { new Widget { Id = Guid.NewGuid(), Color = "Brown", Shape = "Tube" }, new Widget { Id = Guid.NewGuid(), Color = "Black", Shape = "Knob" }, }); break; } _context.SaveChanges(); }