Exemplo n.º 1
0
        public async Task <IActionResult> UpdateTaskAsync(TaskInfo task, CancellationToken cancellationToken)
        {
            if (!ModelState.IsValid)
            {
                var errors = ModelState.StringifyModelErrors();
                return(BadRequest(errors));
            }
            if (task == null)
            {
                return(BadRequest("task is null."));
            }

            var taskToUpdate = _dataRepository.GetTask(task.TaskId);

            if (taskToUpdate == null)
            {
                return(NotFound("The task record couldn't be found."));
            }

            return(Ok(await _dataRepository.UpdateTask(task, taskToUpdate)));
        }