public IActionResult Create([Bind("Id,Name,PetType")] Pet pet)
 {
     if (ModelState.IsValid)
     {
         _context.Add(pet);
         _context.SaveChanges();
         return(RedirectToAction(nameof(Index)));
     }
     return(View(pet));
 }
Exemple #2
0
 public IActionResult Create([Bind("Id,Name,PhoneNumber")] CareTaker careTaker)
 {
     if (ModelState.IsValid)
     {
         _context.Add(careTaker);
         _context.SaveChanges();
         return(RedirectToAction(nameof(Index)));
     }
     return(View(careTaker));
 }
 public IActionResult Create([Bind("Id,CareTakerId,PetId,Start,End")] PetCareSession petCareSession)
 {
     if (ModelState.IsValid)
     {
         _context.Add(petCareSession);
         _context.SaveChanges();
         return(RedirectToAction(nameof(Index)));
     }
     ViewData["CareTakerId"] = new SelectList(_context.CareTaker, "Id", "Id", petCareSession.CareTakerId);
     ViewData["PetId"]       = new SelectList(_context.Pet, "Id", "Id", petCareSession.PetId);
     return(View(petCareSession));
 }