public async Task <ProjectQueryModel> Project(int id) { var users = this.masterDbContext.Users.GroupBy(u => u.ProjectId); var project = await this.projectDbContext.Projects.FirstOrDefaultAsync(q => q.Id == id); if (project != null) { var result = new ProjectQueryModel { ProjectId = project.Id, ProjectName = project.ProjectName, StartingDate = project.StartingDate, Users = (await users?.FirstOrDefaultAsync(q => q.Key == project.Id)).Select(u => new UserQueryModel { UserId = u.UserId, Address = u.Address, Age = u.Age, FirstName = u.FirstName, LastName = u.LastName, ProjectId = u.ProjectId }).ToList() }; return(result); } return(null); }
public async Task<IResultModel> Query(ProjectQueryModel model) { var result = new QueryResultModel<ProjectEntity> { Rows = await _repository.Query(model), Total = model.TotalCount }; return ResultModel.Success(result); }
public async Task <ProjectQueryResultModel> GetFilteredProjectsAsync([FromBody] ProjectQueryModel searchTerms) { using (var context = new PortfolioContext()) { ProjectQueryResultModel result = null; var filteredQuery = from p in context.Projects.IncludeQueryResult() where p.Reservation.Portfolio.ViewKey == searchTerms.PortfolioViewKey select p; var config = await context.PortfolioConfigurations.SingleAsync(p => p.Portfolio.ViewKey == searchTerms.PortfolioViewKey); var filterBuilder = new ProjectSearchFilters(searchTerms, filteredQuery, config); filterBuilder.BuildFilters(); filteredQuery = filterBuilder.Query; result = PortfolioMapper.ProjectMapper.Map <ProjectQueryResultModel>(await filteredQuery.OrderByDescending(p => p.Priority).ToArrayAsync()); return(result); } }
public async Task <IList <ProjectEntity> > Query(ProjectQueryModel model) { var paging = model.Paging(); var query = Db.Find(m => m.Deleted == false); query.WhereIf(model.Name.NotNull(), m => m.Name.Contains(model.Name)); query.WhereIf(model.Code.NotNull(), m => m.Code.Contains(model.Code)); if (!paging.OrderBy.Any()) { query.OrderByDescending(m => m.Id); } var result = await query.LeftJoin <AccountEntity>((x, y) => x.CreatedBy == y.Id) .Select((x, y) => new { x, Creator = y.Name }) .PaginationAsync(paging); model.TotalCount = paging.TotalCount; return(result); }
public void OnGet(string id) { ProjectDetails = _projectQuery.GetProjectDetails(id); }
public async Task <IResultModel> Query([FromQuery] ProjectQueryModel model) { return(await _service.Query(model)); }
public ProjectSearchFilters(ProjectQueryModel searchTerms, IQueryable <Project> filteredQuery, PortfolioConfiguration config) { this.searchTerms = searchTerms; this.Query = filteredQuery; this.config = config; }