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()); }
public async Task <IActionResult> UpdatetoDoItem(long id, toDoItemDTO toDoItemDTO) { if (id != toDoItemDTO.Id) { return(BadRequest()); } var toDoItem = await _context.TodoItems.FindAsync(id); if (toDoItem == null) { return(NotFound()); } toDoItem.Name = toDoItemDTO.Name; toDoItem.IsComplete = toDoItemDTO.IsComplete; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) when(!toDoItemExists(id)) { return(NotFound()); } return(NoContent()); }