public async Task <IActionResult> PutTask(int id, Task task) { if (id != task.Id) { return(BadRequest()); } _context.Entry(task).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TaskExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <ActionResult <Task> > PostTask(Task task) { int maxId = _context.Task.Max(t => t.Id); task.Id = maxId; _context.Task.Add(task); await _context.SaveChangesAsync(); return(CreatedAtAction("GetTask", new { id = task.Id }, task)); }