public async Task <IActionResult> GetallApprovedTrainee(Guid courseid, CancellationToken cancellationToken) { var search = Query <User> .Create(x => x.DisplayName.ToUpper().Contains(string.Empty)); var query = new EntityQuery <Core.Data.Entities.User>(search, 1, int.MaxValue, string.Empty); var command = new UserPaidCommand <Core.Data.Entities.User>(query, courseid); var readModel = await Mediator.Send(command, cancellationToken).ConfigureAwait(false); var result = Cache.GetOrAdd($"{CacheKey.NotInCourse.ToString()}", s => readModel); return(new OkObjectResult(new { Data = result, Status = StatusCodes.Status200OK })); }
protected override async Task <EntityListResult <UserReadModel> > ProcessAsync(UserPaidCommand <Core.Data.Entities.User> message, CancellationToken cancellationToken) { var user = await _dataContext.PaymentTransactions .Include(x => x.UserProfile) .ThenInclude(x => x.User) .Where(x => x.Status == (int)Enum.PaymentStatus.Approved) .ProjectTo <UserReadModel>(_configurationProvider) .ToListAsync(cancellationToken); if (user.Count() > 0) { var attendee = await _dataContext.TrainingBuildCourseAttendees .Include(x => x.Attendee) .Where(x => x.CourseId == message.CourseId) .ProjectTo <UserReadModel>(_configurationProvider) .ToListAsync(cancellationToken); var result = attendee.Count() > 0 ? user.Where(b => !attendee.Any(a => a.Id == b.Id)).ToList() : user.ToList(); return(new EntityListResult <UserReadModel> { Data = result.AsReadOnly() }); } return(new EntityListResult <UserReadModel> { Data = _emptyList.Value }); }