Example #1
0
        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);
        }
Example #2
0
 public ActionResult Edit(Vet vet)
 {
     if (ModelState.IsValid)
     {
         db.Entry(vet).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     return View(vet);
 }