Ejemplo n.º 1
0
        /// <summary>
        /// Get a specific project by its id
        /// </summary>
        /// <param name="projectId">id of the project to retrieve</param>
        /// <returns>a facade that manages the retrieved project or null if no one is found</returns>
        public ProjectFacade Get(int projectId)
        {
            _projectRepository = new PivotalProjectRepository(this.RootFacade.Token);
            var lProject = _projectRepository.GetProject(projectId);

            if (lProject == null)
            {
                return(null);
            }

            var lFacade = new ProjectFacade(this, lProject);

            return(lFacade);
        }
        /// <summary>
        /// Get a specific project by its id
        /// </summary>
        /// <param name="projectId">id of the project to retrieve</param>
        /// <returns>a facade that manages the retrieved project or null if no one is found</returns>
        public async Task <ProjectFacade> GetAsync(int projectId)
        {
            _projectRepository = new PivotalProjectRepository(this.RootFacade.Token);
            var lProject = await _projectRepository.GetProjectAsync(projectId);

            if (lProject == null)
            {
                return(null);
            }

            var lFacade = new ProjectFacade(this, lProject);

            return(lFacade);
        }
Ejemplo n.º 3
0
        public ProjectRepository(
            PivotalProjectRepository pivotalProjectRepository,
            PivotalStoryRepository pivotalStoryRepository)
        {
            Mapper.CreateMap <PivotalProject, Project>();
            Mapper.CreateMap <PivotalStory, Story>()
            .ForMember(s => s.Title, s => s.MapFrom(st => st.Name))
            .ForMember(s => s.Points, s => s.MapFrom(st => st.Estimate))
            .ForMember(s => s.State, s => s.MapFrom(st => st.CurrentState))
            .ForMember(s => s.Labels, s => s.MapFrom(st => st.Labels))
            .ForMember(s => s.Owner, s => s.MapFrom(st => st.OwnedBy));

            _pivotalProjectRepository = pivotalProjectRepository;
            _pivotalStoryRepository   = pivotalStoryRepository;
        }
Ejemplo n.º 4
0
        //TODO: Not tested
        /// <summary>
        /// Get a Project facade for the first project that match the predicate
        /// </summary>
        /// <param name="predicate">predicate to match</param>
        /// <returns>a facade that manage the found project or null if no project was found</returns>
        public ProjectFacade FindProject(Predicate <Project> predicate)
        {
            _projectRepository = new PivotalProjectRepository(this.RootFacade.Token);
            var list = _projectRepository.GetProjects();

            foreach (var project in list)
            {
                if (predicate(project))
                {
                    return(new ProjectFacade(this, project));
                }
            }

            return(null);
        }
        //TODO: Not tested
        /// <summary>
        /// Get a Project facade for the first project that match the predicate
        /// </summary>
        /// <param name="predicate">predicate to match</param>
        /// <returns>a facade that manage the found project or null if no project was found</returns>
        public async Task <ProjectFacade> FindProjectAsync(Predicate <Project> predicate)
        {
            _projectRepository = new PivotalProjectRepository(this.RootFacade.Token);
            var list = await _projectRepository.GetProjectsAsync();

            foreach (var project in list)
            {
                if (predicate(project))
                {
                    return(new ProjectFacade(this, project));
                }
            }

            return(null);
        }
        /// <summary>
        /// Get all projects
        /// </summary>
        /// <returns>a list of facades those manages the retrieved projects or null if no one is found</returns>
        public async Task <List <ProjectFacade> > GetAllAsync()
        {
            _projectRepository = new PivotalProjectRepository(this.RootFacade.Token);
            var lProjects = await _projectRepository.GetProjectsAsync();

            if (lProjects == null)
            {
                return(null);
            }

            List <ProjectFacade> projectFacadeList = new List <ProjectFacade>();

            foreach (var lProject in lProjects)
            {
                projectFacadeList.Add(new ProjectFacade(this, lProject));
            }

            return(projectFacadeList);
        }
Ejemplo n.º 7
0
 public ProjectFacade(ProjectsFacade parent, Project project)
     : base(parent, project)
 {
     _repository = new Repository.PivotalProjectRepository(this.RootFacade.Token);
 }