public async Task <IActionResult> UpdateTaskAsync( Guid taskid, [FromBody] TodoTaskUpdate form, CancellationToken ct) { var task = await _repository.UpdateTaskAsync(taskid, form, ct); if (task == false) { return(NotFound()); } return(Accepted()); }
public async Task <bool> UpdateTaskAsync( Guid taskId, TodoTaskUpdate task, CancellationToken ct ) { var entity = await _dbContext.Tasks.FirstOrDefaultAsync(x => x.Id == taskId); if (entity == null) { return(false); } entity.IsDone = task.IsDone; if (task.Name != null) { entity.Name = task.Name; } if (task.Description != null) { entity.Description = task.Description; } _dbContext.Update(entity); var result = await _dbContext.SaveChangesAsync(ct); if (result >= 1) { return(true); } else { return(false); } }