public async System.Threading.Tasks.Task DeleteAsync(Data.Entities.TaskList taskList, CancellationToken token)
        {
            if (taskList == null)
            {
                throw new ArgumentNullException(nameof(taskList));
            }

            _taskListRepository.Delete(taskList);

            await _unitOfWork.SaveAsync(token);
        }
 public TaskListDto MapToDto(Data.Entities.TaskList taskList)
 {
     return(new TaskListDto
     {
         Id = taskList.Id,
         Name = taskList.Name,
         Tasks = taskList.Tasks != null
             ? taskList.Tasks.Select(task => _taskMapper.MapToDto(task)).ToArray()
             : Array.Empty <TaskDto>()
     });
 }
        public async Task <Data.Entities.TaskList> AddAsync(Data.Entities.TaskList taskList, CancellationToken token)
        {
            if (taskList == null)
            {
                throw new ArgumentNullException(nameof(taskList));
            }

            _taskListRepository.Add(taskList);
            await _unitOfWork.SaveAsync(token);

            return(taskList);
        }
        public async System.Threading.Tasks.Task UpdateNameAsync(int id, string name, CancellationToken token)
        {
            if (string.IsNullOrWhiteSpace(name))
            {
                throw new ArgumentException("is null or white space", nameof(name));
            }

            if (id <= 0)
            {
                throw new ArgumentException("must be more then zero", nameof(id));
            }

            Data.Entities.TaskList taskList = await _taskListRepository.GetByIdAsync(id, token);

            if (taskList == null)
            {
                throw new ArgumentException("not found task with such id", nameof(id));
            }

            taskList.Name = name;

            await _unitOfWork.SaveAsync(token);
        }