public ActionResult Create(Pet pet, int CustomerId) { _dataBase.Pets.Add(pet); if (CustomerId != 0) { _dataBase.CustomerPets.Add(new CustomerPet() { CustomerId = CustomerId, PetId = pet.PetId }); } _dataBase.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Create(Customer new_customer, int PetId) { _dataBase.Customers.Add(new_customer); if (PetId != 0) { _dataBase.CustomerPets.Add(new CustomerPet() { PetId = PetId, CustomerId = new_customer.CustomerId }); } _dataBase.SaveChanges(); return(RedirectToAction("Index")); }