예제 #1
0
 public IActionResult Create([Bind("Id,Name,PetType")] Pet pet)
 {
     if (ModelState.IsValid)
     {
         _context.Add(pet);
         _context.SaveChanges();
         return(RedirectToAction(nameof(Index)));
     }
     return(View(pet));
 }
예제 #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));
 }