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(TaskDto task) { var newTask = new Task { Title = task.Title, Description = task.Description, Status = task.Status }; _context.Task.Add(newTask); await _context.SaveChangesAsync(); return(CreatedAtAction("GetTask", new { id = newTask.Id }, task)); }