Ejemplo n.º 1
0
        public async Task <GetProjectsResponse> GetProjects(GetProjectsRequest request)
        {
            Ensure.NotNull(request);
            var user = _userService.Get(GetUserId());

            return(await _jiraService.GetProjects(request));
        }
Ejemplo n.º 2
0
        public async Task <HandlerResponse <List <Project> > > Handle(GetProjectsRequest request, CancellationToken cancellationToken)
        {
            var projects = await _dataContext.Projects.AsNoTracking().ToListAsync(cancellationToken);

            return(!projects.Any()
                ? new HandlerResponse <List <Project> >(success: false, message: "No Projects exist")
                : new HandlerResponse <List <Project> >(projects));
        }
Ejemplo n.º 3
0
        public async Task <IEnumerable <ProjectDto> > GetProjects(string organization = default, CancellationToken cancellationToken = default)
        {
            var request = new GetProjectsRequest(organization ?? _options.Value.DefaultOrganization);

            request.Headers.Authorization = GetAuthZHeader();

            var response = await SendAsync(request, cancellationToken);

            var projectDtos = await response.Content.ReadFromJsonAsync <VstsListResult <List <ProjectDto> > >(null, cancellationToken);

            return(projectDtos.Value);
        }
Ejemplo n.º 4
0
        public async Task <GetProjectsResponse> GetNewProjects(GetProjectsRequest request)
        {
            Ensure.NotNull(request);
            var response = await _jiraService.GetProjects(request);

            var dbProjects  = _projectService.GetAll();
            var newProjects = response.Values.Where(p => dbProjects.All(dp => dp.JiraId != p.Id)).ToArray();

            return(new GetProjectsResponse
            {
                Values = newProjects
            });
        }
Ejemplo n.º 5
0
        public ActionResult <GetProjectsResponse> Get(GetProjectsRequest request)
        {
            var roleId = User.Identity.GetUserRoleId <int>();
            var userId = User.Identity.GetUserId <int>();

            if (roleId == int.Parse(RolesResources.Administrator))
            {
                return(Ok(repository.Get(request)));
            }
            else
            {
                return(Ok(repository.Get(userId, request)));
            }
        }
Ejemplo n.º 6
0
        public GetProjectsResponse Get(GetProjectsRequest item)
        {
            var result = new GetProjectsResponse();

            result.CountElements = db.Projects.Count();

            var projects = db.Projects.Skip(item.Offset).Take(item.Limit);

            foreach (var project in projects)
            {
                result.Projects.Add(Mapping(project));
            }
            return(result);
        }
Ejemplo n.º 7
0
        public void CanBeConstructed()
        {
            //Arrange
            GetProjectsRequest sut;

            //Act
            sut = new GetProjectsRequest("my-org");

            //Assert
            Assert.NotNull(sut);
            Assert.Equal("6.0", sut.ApiVersion);
            Assert.Equal(HttpMethod.Get, sut.Method);
            Assert.Equal("https://dev.azure.com/my-org/_apis/projects?api-version=6.0", sut.RequestUri.AbsoluteUri);
        }
Ejemplo n.º 8
0
        public GetProjectsResponse Get(int userId, GetProjectsRequest item)
        {
            var result = new GetProjectsResponse();

            result.CountElements = db.Projects.Where(p => p.ID == userId).Count();

            var projects = db.Projects
                           .SelectMany(p => p.ProjectUsers, (p, u) => new { Project = p, ProjectUser = u })
                           .Where(p => p.ProjectUser.UserID == 1).Select(p => p.Project);

            foreach (var project in projects)
            {
                result.Projects.Add(Mapping(project));
            }
            return(result);
        }
Ejemplo n.º 9
0
        public async override Task <GetProjectsReply> GetProjects(GetProjectsRequest request, Grpc.Core.ServerCallContext context)
        {
            List <Domain.Project> projects = new List <Domain.Project>()
            {
                new Domain.Project
                {
                    Id               = 1,
                    Title            = "Project #1",
                    ShortDescription = "Short description of the project #1",
                    Description      = "Description of the project #1",
                    Inserted         = DateTime.Now.AddDays(-5),
                    LastUpdated      = DateTime.Now
                },
                new Domain.Project
                {
                    Id               = 2,
                    Title            = "Project #2",
                    ShortDescription = "Short description of the project #2",
                    Description      = "Description of the project #2",
                    Inserted         = DateTime.Now.AddDays(-5),
                    LastUpdated      = DateTime.Now
                },
                new Domain.Project
                {
                    Id               = 3,
                    Title            = "Project #3",
                    ShortDescription = "Short description of the project #3",
                    Description      = "Description of the project #3",
                    Inserted         = DateTime.Now.AddDays(-3),
                    LastUpdated      = DateTime.Now
                }
            };

            var reply = new GetProjectsReply();

            reply.TotalCount = 3;
            reply.PageSize   = 10;
            reply.PageNumber = 1;
            reply.Projects.AddRange(projects.Select(p => p.ToGrpc()));
            return(reply);
        }
Ejemplo n.º 10
0
        public async Task <GetProjectsResponse> GetProjects(GetProjectsRequest request)
        {
            Ensure.NotNull(request);

            const string endpoint = "rest/api/3/project/search";

            using (var client = new HttpClient())
            {
                client.BaseAddress = BaseAddress;
                client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", AuthHeader);
                var response = await client.GetAsync(endpoint);

                if (!response.IsSuccessStatusCode)
                {
                    return(new GetProjectsResponse
                    {
                        FailureMessage = $"Request ended with a status code of {response.StatusCode}|"
                    });
                }
                return(JsonConvert.DeserializeObject <GetProjectsResponse>(await response.Content.ReadAsStringAsync()));
            }
        }
Ejemplo n.º 11
0
        public ProjectEntityResponse GetProjects(string searchStr)
        {
            ProjectEntityResponse result = new ProjectEntityResponse();

            try
            {
                var request = new GetProjectsRequest()
                {
                    SearchStr = searchStr,
                    PageIndex = 1,
                    PageSize  = 99999
                };

                result = this.Client.InvokeAPI <ProjectEntityResponse>(request);
            }
            catch (Exception ex)
            {
                result.Code   = 9999;
                result.ErrMsg = ex.Message;
            }

            return(result);
        }
Ejemplo n.º 12
0
 public ServiceResponse<List<Project>> GetProjects(GetProjectsRequest request)
 {
     var response = new ServiceResponse<List<Project>> {Time = DateTime.Now, ServiceMessage = ""};
     try
     {
         response.Result = DataAccessor.RunProc<Project>("sp_GetProjects");
         response.IsSuccess = true;
     }
     catch (Exception ex)
     {
         response.IsSuccess = false;
         response.Result = new List<Project>();
         response.ServiceMessage = "An exception occurred in GetProjects: " + ex.Message;
     }
     return response;
 }
Ejemplo n.º 13
0
 public async Task <List <ProjectDisplayModel> > Handle(GetProjectsRequest message, CancellationToken cancellationToken)
 {
     return((await _documentDataContext.Projects.AsNoTracking().Where(p => !p.IsDeleted).ToListAsync(cancellationToken: cancellationToken))
            .Select(s => s.ToModel()).ToList());
 }