public async Task <List <Tasks.Dtos.Task> > Handle(GetDriverTaskQuery request, CancellationToken cancellationToken) { return(await _memoryCache.GetOrCreate(request.DriverId.ToString(), async options => { options.AbsoluteExpiration = DateTime.Now.AddSeconds(1); var tasks = await _tasksRepository.GetTasksByDriverIdAsync(request.DriverId); if (tasks == null) { throw new NotFoundException(); } List <Dtos.Task> result = new List <Dtos.Task>(); foreach (var task in tasks) { task.Logist = await _usersRepository.GetUserByIdAsync(task.LogistId); task.Driver = await _usersRepository.GetUserByIdAsync(task.DriverId); result.Add(task.ToQueryTask()); } return result; })); }