public ActionResult Create(Vet vet) { if (ModelState.IsValid) { var allProducts = db.Products; vet.AvailableProducts = new Collection<Product>(); foreach (var product in allProducts) { db.Entry(product).State = EntityState.Modified; vet.AvailableProducts.Add(product); } db.Vets.Add(vet); db.SaveChanges(); return RedirectToAction("Index"); } return View(vet); }
public ActionResult Edit(Vet vet) { if (ModelState.IsValid) { db.Entry(vet).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } return View(vet); }