public async Task <ActionResult> UpdateTask(int id, UserTaskUpdateDTO taskUpdateDTO)
        {
            try
            {
                string token = HttpContext.Request.Headers["authorization"].Single().Split(" ")[1];
                if (!await _repository.ValidateToken(token))
                {
                    return(Unauthorized());
                }

                var taskModelFromRepository = await _repository.GetTaskById(id);

                if (taskModelFromRepository == null)
                {
                    return(NotFound());
                }
                int loggedUserId = Int32.Parse(User.FindFirst(ClaimTypes.NameIdentifier)?.Value);
                if (taskModelFromRepository.userId != loggedUserId)
                {
                    return(Unauthorized());
                }

                if (!await _repository.IsAdvancedUser(loggedUserId))
                {
                    taskUpdateDTO.text = null;
                }

                _mapper.Map(taskUpdateDTO, taskModelFromRepository);

                await _repository.UpdateTask(taskModelFromRepository);

                return(Ok(_mapper.Map <UserTaskReadDTO>(taskModelFromRepository)));
            }
            catch (Exception)
            {
                return(new StatusCodeResult(StatusCodes.Status500InternalServerError));
            }
        }
        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)));
        }