public async Task <ActionResult <PetCareSession> > PostPetCareSession(PetCareSession petCareSession) { _context.PetCareSession.Add(petCareSession); await _context.SaveChangesAsync(); return(CreatedAtAction("GetPetCareSession", new { id = petCareSession.Id }, petCareSession)); }
public IActionResult Edit(int id, [Bind("Id,CareTakerId,PetId,Start,End")] PetCareSession petCareSession) { if (id != petCareSession.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(petCareSession); _context.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!PetCareSessionExists(petCareSession.Id)) { return(NotFound()); } else { throw; } } 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)); }
public async Task <IActionResult> PutPetCareSession(int id, PetCareSession petCareSession) { if (id != petCareSession.Id) { return(BadRequest()); } _context.Entry(petCareSession).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PetCareSessionExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
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)); }