public async Task ShouldReturnAllProjectssAndIssues() { // Arrange var userId = await RunAsDefaultUserAsync(); var owner = new Participant(userId, "firstName", "lastName"); var project = new Project(owner, "Project Name", "Key"); project.AddIssue(new Issue(project, owner, IssueType.Story, "title")); await AddAsync(project); var query = new GetProjectsQuery(); // Act var result = await SendAsync(query); // Assert result.Projects.Should().HaveCount(1); result.Projects.First().Key.Should().Be(project.Key); result.Projects.First().Name.Should().Be(project.Name); result.Projects.First().Owner.Should().Be($"{project.Owner.FirstName} {project.Owner.LastName}"); result.Projects.First().Issues.Should().HaveCount(project.Issues.Count); result.Projects.First().Participants.Should().HaveCount(project.Participants.Count); }
public async Task <List <Project> > Handle(GetProjectsQuery request, CancellationToken cancellationToken) { var filter = Builders <Project> .Filter; var query = filter.In("_id", request.Projects); return(_db.Find(query).ToList()); }
public async Task<List<Project>> UserProects() { GetProjectsQuery query = new GetProjectsQuery(new List<string>()); var result = await _mediator.Send(query); return result; }
public async Task <IActionResult> GetAllProjects() { var query = new GetProjectsQuery(); var result = await this.mediator.Send(query); return(result.ToActionResult()); }
public HttpResponseMessage Get() { var projectQueryService = new ProjectQueryService(); var getProjectsQuery = new GetProjectsQuery(); var projects = projectQueryService.Execute(getProjectsQuery); return(Request.CreateResponse(HttpStatusCode.OK, projects)); }
public IActionResult Get() { var query = new GetProjectsQuery(); var result = _bus.PublishQuery(query); var project = JsonConvert.DeserializeObject <List <ProjectViewModel> >(result); return(new JsonResult(project)); }
public async Task <List <GetProjectResponse> > Handle(GetProjectsQuery request, CancellationToken cancellationToken) { var result = await _efContext.Projects.Select(x => new GetProjectResponse() { Project = x }).ToListAsync(); return(result); }
public async Task <IActionResult> Get() { var getProjectsCommand = new GetProjectsQuery(User); var getProjectsResult = await _mediator.Send(getProjectsCommand); return(getProjectsResult.IsSuccess ? Ok(getProjectsResult.Value) : BadRequest(getProjectsResult.Error)); }
public List <ProjectViewModel> Execute(GetProjectsQuery query) { var viewModels = new List <ProjectViewModel>(); foreach (var file in Directory.GetFiles(_storageFolder, "project-*")) { var fileContent = File.ReadAllText(file); var viewModel = JsonConvert.DeserializeObject <ProjectViewModel>(fileContent); viewModels.Add(viewModel); } return(viewModels); }
public async Task <IActionResult> GetAllProjectsAsync([FromQuery] GetProjectsFilters filters) { var userId = Guid.Parse(User.FindFirst(ClaimTypes.NameIdentifier)?.Value); var query = new GetProjectsQuery(userId, filters); var result = await _mediator.Send(query); if (!result.Success) { return(BadRequest(new ErrorResource(result.Message))); } var projectsResource = _mapper.Map <IEnumerable <Project>, IEnumerable <ProjectResource> >(result.Projects); return(Ok(projectsResource)); }
public async Task <IEnumerable <ProjectDto> > Handle(GetProjectsQuery request, CancellationToken cancellationToken) { var connection = _connectionFactory.GetOpenConnection(); const string sql = @" SELECT id, name, description, ""recruitingStatus"", type, category FROM public.""Projects"""; var projects = await connection.QueryAsync <ProjectDto>(sql); return(projects); }
private List <ViewModels.ProjectModel> GetProjectList() { var query = new GetProjectsQuery(); var projects = mediator.Send(query); var projectList = new List <ViewModels.ProjectModel>(); foreach (var item in projects) { projectList.Add(new ViewModels.ProjectModel { Id = item.Id, Name = item.Name }); } return(projectList); }
public async Task TestGetMethod() { // Arrange TestLambdaContext context; APIGatewayProxyRequest request; APIGatewayProxyResponse response; request = new APIGatewayProxyRequest { Headers = new Dictionary <string, string>() }; context = new TestLambdaContext(); var functions = new GetProjectsQuery(); // Act response = await functions.RunHandler(request, context); // Assert Assert.Equal(200, response.StatusCode); Assert.NotEmpty(response.Body); }
public Task <List <ProjectVm> > Handle(GetProjectsQuery request, CancellationToken cancellationToken) { try { var projects = _dbContext.Projects.Where(p => p.IsDeleted == false); List <ProjectVm> projectsVm = new(); foreach (var item in projects) { projectsVm.Add(new ProjectVm { Id = item.Id, Description = item.Description, Title = item.Title, Type = item.Type }); } return(Task.FromResult(projectsVm)); } catch (Exception ex) { throw new Exception("There was an error getting the projects", ex); } }
public async Task <List <ProjectDto> > Handle(GetProjectsQuery request, CancellationToken cancellationToken) { return(await _context.Projects .ProjectTo <ProjectDto>(_mapper.ConfigurationProvider) .ToListAsync()); }
public async Task <IEnumerable <ProjectDto> > Handle(GetProjectsQuery request, CancellationToken cancellationToken) { return(await _context.Project.ProjectTo <ProjectDto>(_mapper.ConfigurationProvider) .OrderBy(t => t.Title) .ToListAsync(cancellationToken)); }
public async Task <IActionResult> GetProjects([FromQuery] GetProjectsQuery project) { var result = await Mediator.Send(project); return(Ok(result)); }
public async Task <ActionResult <List <ProjectDto> > > GetProjects([FromQuery] GetProjectsQuery query) { return(await Mediator.Send(query)); }
public async Task <ActionResult <ProjectListResult> > ListAsync([FromQuery] GetProjectsQuery request) { return(await this.Mediator.Send(request)); }
public async Task <IActionResult> GetProjects(GetProjectsQuery request) { var response = await _mediator.Send(request); return(Ok(response)); }