public async Task <IActionResult> Edit(int id, [Bind("Id,Date,RecallDate,BatchNumber,PersonId,VaccineId")] Vacciner vaccinate) { if (id != vaccinate.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(vaccinate); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!VaccinerExists(vaccinate.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["PersonId"] = new SelectList(_context.Persons, "Id", "Firstname", vaccinate.PersonId); ViewData["VaccineId"] = new SelectList(_context.Vaccines, "Id", "Brand", vaccinate.VaccineId); return(View(vaccinate)); }
public async Task <IActionResult> Create([Bind("Id,Date,RecallDate,BatchNumber,PersonId,VaccineId")] Vacciner vaccinate) { if (ModelState.IsValid) { _context.Add(vaccinate); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["PersonId"] = new SelectList(_context.Persons, "Id", "Firstname", vaccinate.PersonId); ViewData["VaccineId"] = new SelectList(_context.Vaccines, "Id", "Brand", vaccinate.VaccineId); return(View(vaccinate)); }