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