public IActionResult Post([FromBody] models.Task task) { var maxId = _tasks.Max(t => t.Id); task.Id = maxId + 1; _tasks.Add(task); return(Created($@"http://localhost:60430/api/tasks/{task.Id}", task)); }
public IActionResult Put(int id, [FromBody] models.Task task) { var taskFromMemory = _tasks.SingleOrDefault(t => t.Id == id); if (taskFromMemory == null) { return(NotFound()); } taskFromMemory.Title = task.Title; return(Ok(taskFromMemory)); }