public async Task <IActionResult> GetAsync([FromQuery] QueryProjectsRequest request) { if (request.IsPrivate == true && !User.IsInRole(nameof(RoleType.Admin))) { return(Unauthorized()); } var projectsQuery = new ProjectsQuery( request.Offset, request.Count, request.IsPrivate, request.OnlyScored, request.SearchString, request.Stage, request.CountryCode, request.Category, request.MinimumScore, request.MaximumScore, request.OrderBy, request.SortDirection, request.ScoringStatuses ?? new List <ScoringStatus>(), request.ProjectIds ?? new List <long>() ); var projects = await _projectService.GetAsync(projectsQuery); var scoringsApplications = await _scoringApplicationRepository.GetByProjectIdsAsync(projects.Select(i => i.Id).ToArray()); return(Ok(projects.ToPartialCollectionResponse(p => ProjectResponse.Create(p, scoringsApplications.FirstOrDefault(s => s.ProjectId == p.Id))))); }
public async Task Search(IDialogContext context, IAwaitable <IMessageActivity> activity, LuisResult result) { var message = await activity; var projectsQuery = new ProjectsQuery(); var projectsFormDialog = new FormDialog <ProjectsQuery>(projectsQuery, this.BuildProjectsForm, FormOptions.PromptInStart, result.Entities); context.Call(projectsFormDialog, this.ResumeAfterProjectsFormDialog); }
public async Task <IEnumerable <ProjectDto> > Handle(ProjectsQuery request, CancellationToken cancellationToken) { if (request == null) { throw new ArgumentNullException(nameof(request)); } var projects = await _context.Projects .Include(p => p.Author) .Include(p => p.Team) .ToListAsync(); return(_mapper.Map <IEnumerable <ProjectDto> >(projects)); }
public Task <PagingCollection <Project> > GetAsync(ProjectsQuery query) { var queryable = from project in Entities() join scoringApplication in _editContext.ScoringApplications on project.Id equals scoringApplication.ProjectId into ps from scoringApplication in ps.DefaultIfEmpty() where !query.OnlyScored || project.Scoring.Score.HasValue where !query.Stage.HasValue || project.Stage == query.Stage.Value where string.IsNullOrEmpty(query.SearchString) || project.Name.ToUpper().Contains(query.SearchString.ToUpper()) where string.IsNullOrEmpty(query.CountryCode) || project.Country.Code == query.CountryCode.ToUpper() where !query.Category.HasValue || project.Category == query.Category.Value where !query.MinimumScore.HasValue || (project.Scoring.Score.HasValue && project.Scoring.Score.Value >= query.MinimumScore) where !query.MaximumScore.HasValue || (project.Scoring.Score.HasValue && project.Scoring.Score.Value <= query.MaximumScore) where (!query.IsPrivate.HasValue && project.IsPrivate == false) || (query.IsPrivate.HasValue && project.IsPrivate == query.IsPrivate && scoringApplication.IsSubmitted) where query.ScoringStatuses.Count == 0 || query.ScoringStatuses.Contains(project.Scoring.Status) || query.ScoringStatuses.Contains(ScoringStatus.Pending) && project.Scoring == null where query.ProjectIds.Count == 0 || query.ProjectIds.Contains(project.Id) select project; if (query.OrderBy.HasValue) { switch (query.OrderBy) { case ProjectsOrderBy.Name: queryable = query.Direction == SortDirection.Ascending ? queryable.OrderBy(o => o.Name) : queryable.OrderByDescending(i => i.Name); break; case ProjectsOrderBy.ScoringRating: queryable = query.Direction == SortDirection.Ascending ? queryable.OrderBy(o => o.Scoring.Score) : queryable.OrderByDescending(i => i.Scoring.Score); break; case ProjectsOrderBy.ScoringEndDate: queryable = query.Direction == SortDirection.Ascending ? queryable.OrderBy(o => o.Scoring.ScoringEndDate) : queryable.OrderByDescending(o => o.Scoring.ScoringEndDate); break; case ProjectsOrderBy.CreationDate: queryable = query.Direction == SortDirection.Ascending ? queryable.OrderBy(o => o.Id) : queryable.OrderByDescending(o => o.Id); break; } } return(queryable.GetPageAsync(query.Offset, query.Count)); }
public Task <IActionResult> GetUsers(ProjectsQuery query) => ExecuteQuery(query);
public Task <PagingCollection <Project> > GetAsync(ProjectsQuery query) => _projectRepository.GetAsync(query);