Ejemplo n.º 1
0
        public async Task GetAllProjectsTrueAsync()
        {
            await CreateUserAndMockingHttpContextToReturnAccessToken();

            var responseProjects   = Task.FromResult(_stringConstant.ProjectDetailsForAdminFromOauth);
            var requestUrlProjects = _stringConstant.AllProjectUrl;

            _mockHttpClient.Setup(x => x.GetAsync(_stringConstant.ProjectUrl, requestUrlProjects, _stringConstant.AccessTokenForTest, _stringConstant.Bearer)).Returns(responseProjects);
            var projects = await _oauthCallHttpContextRepository.GetAllProjectsAsync();

            Assert.Equal(1, projects.Count);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Method to return the list of projects depending on the role of the logged in user
        /// </summary>
        /// <param name="userId">userId of user</param>
        /// <returns>List of projects</returns>
        public async Task <IEnumerable <ProjectAc> > GetProjectsAsync(string userId)
        {
            //Getting the details of the logged in user from Oauth server
            User loginUser = await _oauthCallsRepository.GetUserByEmployeeIdAsync(userId);

            List <ProjectAc> projects = new List <ProjectAc>();

            if (loginUser.Role.Equals(_stringConstant.Admin))
            {
                projects = await _oauthCallsRepository.GetAllProjectsAsync();
            }
            else
            {
                projects = await _oauthCallsRepository.GetListOfProjectsEnrollmentOfUserByUserIdAsync(loginUser.Id);
            }
            return(projects);
        }
 /// <summary>
 /// Method to get list of project from oauth server
 /// </summary>
 /// <returns>list of project</returns>
 public async Task <List <ProjectAc> > GetAllProjectAsync()
 {
     // returns list of project which are active
     return((await _oauthCallRepository.GetAllProjectsAsync()).FindAll(x => x.IsActive));
 }