public IActionResult Create() { var viewModel = new CreateUpdatePetViewModel() { Owners = _context.Owners.ToList(), Pet = new Pet() }; return(View(viewModel)); }
public IActionResult Update(int?id) { var viewModel = new CreateUpdatePetViewModel() { Pet = _context.Pets.Find(id), Owners = _context.Owners.ToList() }; return(View(viewModel)); }
public IActionResult Create(CreateUpdatePetViewModel viewModel) { if (!ModelState.IsValid) { return(View()); } _context.Pets.Add(viewModel.Pet); _context.SaveChanges(); return(View("Created", viewModel.Pet)); }