public HttpResponseMessage Get(HttpRequestMessage request, ProjectListType type) { UserProfile theUser = _service.GetUserProfile(_security.GetUserId(User.Identity.Name)); IEnumerable<ProjectListViewModel> list; switch (type) { case ProjectListType.IamArchitect: list = _service.GetEnumerable(s => s.ArchitectId == theUser.CompanyId) .Select(s => new ProjectListViewModel { Architect = s.Architect.CompanyName, Id = s.Id, Title = s.Title, Number = s.Number }); return request.CreateResponse(HttpStatusCode.OK, list); case ProjectListType.MyCreated: list = _service.GetEnumerable(s => s.CreatedById == theUser.UserId) .Select(s => new ProjectListViewModel { Architect = s.Architect.CompanyName, Id = s.Id, Title = s.Title, Number = s.Number }); return request.CreateResponse(HttpStatusCode.OK, list); case ProjectListType.InvitedTo: // get invitations to project IEnumerable<Invitation> invites = _service.GetInvitations(theUser.CompanyId); // get the projects var projects = invites.Select(i => i.BidPackage.Project).Distinct(); // convert to view model list = projects.Select(p => new ProjectListViewModel { Id = p.Id, Title = p.Title, Architect = p.Architect.CompanyName, Number = p.Number }); return request.CreateResponse(HttpStatusCode.OK, list); case ProjectListType.Open: list = _service.GetActivePublicSearchable() .Select(s => new ProjectListViewModel { Architect = s.Architect.CompanyName, Id = s.Id, Title = s.Title, Number = s.Number }); return request.CreateResponse(HttpStatusCode.OK, list); default: return request.CreateResponse(HttpStatusCode.BadRequest); } }
public Project GetActiveProject(ProjectListType projectListType) { using (GitAnalysis ga = new GitAnalysis(GitLabPackage.GetSolutionDirectory())) { var url = ga.GetRepoOriginRemoteUrl(); var pjt = from project in this.GetProjects(projectListType) where string.Equals(project.Url, url, StringComparison.OrdinalIgnoreCase) select project; return(pjt.FirstOrDefault()); } }
public IReadOnlyList <Project> GetProjects(ProjectListType projectListType) { List <Project> lstpjt = new List <Project>(); var user = _storage.GetUser(); if (user == null) { throw new UnauthorizedAccessException(Strings.WebService_CreateProject_NotLoginYet); } var client = NGitLab.GitLabClient.Connect(user.Host, user.PrivateToken, VsApiVersionToNgitLabversion(user.ApiVersion)); NGitLab.Models.Project[] project = null; switch (projectListType) { case ProjectListType.Accessible: project = client.Projects.Accessible().ToArray(); break; case ProjectListType.Owned: project = client.Projects.Owned().ToArray(); break; case ProjectListType.Membership: project = client.Projects.Membership().ToArray(); break; case ProjectListType.Starred: project = client.Projects.Starred().ToArray(); break; default: break; } if (project != null) { foreach (var item in project) { lstpjt.Add(item); } } return(lstpjt); }
public static List <ProjectType> getProjectList(String tokenid) { try{ TokenIdType par = new TokenIdType(tokenid); String response = sendPostCommand("/projectList", par.ToString()); if (response != null) { if (response.Equals(SubscriptionRequired.ERRCODE)) { throw new SubscriptionRequired(); } else { ProjectListType lstProject = ProjectListType.mapJson(response); return(lstProject.getProjectList()); } } } catch (Exception ex) { logError(ex); } return(null); }