public async Task <ActionResult <Task> > PostTask(Task task) { _context.Tasks.Add(task); await _context.SaveChangesAsync(); return(CreatedAtAction("GetTask", new { id = task.Id }, task)); }
public async Task <IActionResult> PutTask(long 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()); }