public async Task <IActionResult> Edit(int id, [Bind("Id,JokeQuestion,JokeAnswer")] joke joke) { if (id != joke.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(joke); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!jokeExists(joke.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(joke)); }
public async Task <IActionResult> Create([Bind("Id,JokeQuestion,JokeAnswer")] joke joke) { if (ModelState.IsValid) { _context.Add(joke); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(joke)); }