public async Task <IActionResult> PutKuchen([FromRoute] int id, [FromBody] Kuchen kuchen) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != kuchen.Id) { return(BadRequest()); } _context.Entry(kuchen).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!KuchenExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> Create([Bind("Id,Name,Bewertung,Schoko")] Kuchen kuchen) { if (ModelState.IsValid) { _context.Add(kuchen); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(kuchen)); }