public ActionResult Create(Pet pet) { if (ModelState.IsValid) { db.Pets.Add(pet); db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.BreedId = new SelectList(db.Breeds.Include(r => r.PetType), "Id", "DisplayName", pet.BreedId); ViewBag.UserId = new SelectList(db.Users, "Id", "FullName", pet.UserId); return View(pet); }
public void SavePet(VMSavePet pet) { var newPet = new Pet() { Name = pet.Name, BreedId = pet.PetBreedId, Birthday = pet.Birthday, UserId = pet.UserId, Weight = pet.Weight }; _db.Pets.Add(newPet); _db.SaveChanges(); }