public void GetProject_NotFoundGetAll(string projectName, string userId) { _projectRepository.GetAll(x => x.Active).ReturnsForAnyArgs(ProjectEmptyList()); var searchDto = new SearchProjectRequestDto { ProjectName = projectName, UserID = userId }; var result = _userDashboardProcessor.GetProjects(searchDto); }
public void GetSolutionHeaderDetailsInProject_UserIdNotFound(string userId, int projectId, string userName) { var searchDto = new SearchProjectRequestDto { UserID = userId, ID = projectId }; var result = _projectProcessor.GetSolutionHeaderDetailsInProject(searchDto, userName); }
public HttpResponseMessage GetSolutionListByProjectID(int ProjectID) { return(CreateHttpResponse(() => { var requestDto = new SearchProjectRequestDto { UserID = UserID, ID = ProjectID }; return Request.CreateResponse(_project.GetSolutionHeaderDetailsInProject(requestDto, UserName)); })); }
public HttpResponseMessage GetProjectDetail(int ProjectID) { return(CreateHttpResponse(() => { var requestDto = new SearchProjectRequestDto { UserID = UserID, ID = ProjectID }; return Request.CreateResponse(_project.GetProjectDetail(requestDto, UserName)); })); }
public HttpResponseMessage GetRecentProjects(int daysOld) { return(CreateHttpResponse(() => { var requestDto = new SearchProjectRequestDto { UserID = UserID, DaysOld = daysOld }; return Request.CreateResponse(_userDashboard.GetProjects(requestDto)); })); }
public void GetProjects_ByName(string projectName, string userId) { _projectRepository.GetAll(x => x.Active).ReturnsForAnyArgs(ProjectList()); var searchDto = new SearchProjectRequestDto { ProjectName = projectName, UserID = userId }; var result = _userDashboardProcessor.GetProjects(searchDto); Assert.AreEqual(result.Count(), 1); }
public void GetProjectDetail_UserIdNotFound(string userName, string userId, int projectId) { _projectRepository.GetAll(x => x.Active).ReturnsForAnyArgs(ProjectList()); var searchDto = new SearchProjectRequestDto { UserID = userId, ID = projectId }; var result = _projectProcessor.GetProjectDetail(searchDto, userName); _projectEntityToProjectDetailDtoMapper.AddMap(Arg.Any <Project>()).DidNotReceive(); }
//[ExpectedException(typeof(PowerDesignProException))] public void GetSolutionHeaderDetailsInProject_SolutionNotFound(string userId, int projectId, string userName) { var searchDto = new SearchProjectRequestDto { UserID = userId, ID = projectId }; _projectRepository.GetSingle( p => p.Active && p.UserID == searchDto.UserID && p.ID == searchDto.ID).ReturnsForAnyArgs(EmptySolutionList().FirstOrDefault(x => x.ID == searchDto.ID)); var result = _projectProcessor.GetSolutionHeaderDetailsInProject(searchDto, userName); }
public void GetProjects_BySolutionName(string solutionName, string userId) { _projectRepository.GetAll(x => x.Active).ReturnsForAnyArgs(ProjectList()); var searchDto = new SearchProjectRequestDto { ProjectName = string.Empty, UserID = userId, SolutionName = solutionName, CreateDate = string.Empty, ModifyDate = string.Empty }; var result = _userDashboardProcessor.GetProjects(searchDto); Assert.AreEqual(result.Count(), 0); }
private ProjectDetailDto SharedProjectDetail(SearchProjectRequestDto searchDto, string userName) { var sharedProject = _sharedProjectRepository.GetSingle(sp => sp.ProjectID == searchDto.ID && sp.RecipientEmail.Equals(userName)); var project = _projectRepository.GetSingle(p => p.Active && p.ID == searchDto.ID); if (sharedProject == null) { throw new PowerDesignProException("ProjectNotFound", Message.ProjectDashboard); } var sharedProjectDetail = _projectEntityToProjectDetailDtoMapper.AddMap(project); sharedProjectDetail.UserName = sharedProjectDetail.CreatedBy; sharedProjectDetail.IsReadOnlyAccess = true; return(sharedProjectDetail); }
public HttpResponseMessage GetProjectsByCreateDate(string createDate) { return(CreateHttpResponse(() => { var requestDto = new SearchProjectRequestDto { ProjectName = string.Empty, UserID = UserID, SolutionName = string.Empty, CreateDate = createDate, ModifyDate = string.Empty }; return Request.CreateResponse(_userDashboard.GetProjects(requestDto)); })); }
public AddProjectResponseDto CopyShareProject(SearchProjectRequestDto searchProjectRequestDto, string userId, string userName) { var Project = _projectRepository.Find(searchProjectRequestDto.ID); Project.ID = 0; Project.CreatedBy = userName; Project.ModifiedDateTime = DateTime.UtcNow; Project.ModifiedBy = userName; Project.ModifiedDateTime = DateTime.UtcNow; Project.Active = true; Project.ProjectName = string.Concat(Project.ProjectName, "– Shared V1"); var projectCount = _projectRepository.GetAll(p => p.UserID == userId && p.Active) .Where(p => p.ProjectName.ToUpper() == Project.ProjectName.ToUpper()) .Count(); if (projectCount > 0) { Project.ProjectName = string.Concat(Project.ProjectName, "– Shared V", projectCount + 1); } Parallel.ForEach(Project.Solutions, solution => { solution.ID = 0; solution.CreatedBy = userName; solution.ModifiedDateTime = DateTime.UtcNow; solution.ModifiedBy = userName; solution.ModifiedDateTime = DateTime.UtcNow; solution.Active = true; solution.SolutionName = string.Concat(solution.SolutionName, "– Shared V1"); var solutionCount = Project.Solutions.Count(s => s.SolutionName.Equals(solution.SolutionName, StringComparison.InvariantCultureIgnoreCase)); if (solutionCount > 0) { solution.SolutionName = string.Concat(solution.SolutionName, "– Shared V", solutionCount + 1); } }); var projectDetail = _projectRepository.Add(Project); _projectRepository.Commit(); return(new AddProjectResponseDto { ProjectID = projectDetail.ID, ProjectName = projectDetail.ProjectName }); }
public void GetProjectDetail_ProjectNotFound(string userName, string userId, int projectId) { var searchDto = new SearchProjectRequestDto { UserID = userId, ID = projectId }; _projectRepository.GetSingle( p => p.Active && p.UserID == searchDto.UserID && p.ID == searchDto.ID).ReturnsForAnyArgs(ProjectList().FirstOrDefault(x => x.ID == searchDto.ID)); var result = _projectProcessor.GetProjectDetail(searchDto, userName); _projectEntityToProjectDetailDtoMapper.AddMap(Arg.Any <Project>()).DidNotReceive(); }
/// <summary> /// Gets the project detail. /// </summary> /// <param name="searchDto">The search dto.</param> /// <param name="userName">Name of the user.</param> /// <returns></returns> /// <exception cref="PowerDesignProException"> /// ProjectNotFound /// or /// ProjectNotFound /// </exception> public ProjectDetailDto GetProjectDetail(SearchProjectRequestDto searchDto, string userName) { if (!string.IsNullOrEmpty(searchDto.UserID) && searchDto.ID > 0) { var projectDetail = _projectRepository.GetSingle(p => p.Active && p.UserID == searchDto.UserID && p.ID == searchDto.ID); if (projectDetail == null) { return(SharedProjectDetail(searchDto, userName)); throw new PowerDesignProException("ProjectNotFound", Message.ProjectDashboard); } var projectDetailDto = _projectEntityToProjectDetailDtoMapper.AddMap(projectDetail, userName: userName); projectDetailDto.IsReadOnlyAccess = false; return(projectDetailDto); } throw new PowerDesignProException("ProjectNotFound", Message.ProjectDashboard); }
/// <summary> /// Gets the projects. /// </summary> /// <param name="searchDto">The search dto.</param> /// <returns></returns> /// <exception cref="PowerDesignProException"> /// ProjectNotFound /// or /// ProjectNotFound /// </exception> public IEnumerable <DashboardProjectDetailDto> GetProjects(SearchProjectRequestDto searchDto) { var projects = _projectRepository.GetAll(p => p.Active && p.UserID == searchDto.UserID); if (projects.Count() == 0 && string.IsNullOrEmpty(searchDto.ProjectName)) { return(new List <DashboardProjectDetailDto>()); } else if (projects.Count() == 0) { throw new PowerDesignProException("ProjectNotFound", Message.ProjectDashboard); } // search by project name if (!string.IsNullOrEmpty(searchDto.ProjectName)) { projects = projects.Where(p => p.ProjectName.ToLower().Contains(searchDto.ProjectName.ToLower())); } // search by solution name if (!string.IsNullOrEmpty(searchDto.SolutionName)) { projects = projects.Where(p => p.Solutions.Where(s => s.SolutionName.ToLower().Contains(searchDto.SolutionName.ToLower())).Count() > 0); } // search by CreateDate of project if (!string.IsNullOrEmpty(searchDto.CreateDate)) { DateTime filterDate = Convert.ToDateTime(searchDto.CreateDate); projects = projects.Where(p => System.Data.Entity.DbFunctions.TruncateTime(p.CreatedDateTime) == filterDate.Date); } // search by modified date of project if (!string.IsNullOrEmpty(searchDto.ModifyDate)) { DateTime filterDate = Convert.ToDateTime(searchDto.ModifyDate); projects = projects.Where(p => System.Data.Entity.DbFunctions.TruncateTime(p.ModifiedDateTime) == filterDate.Date); } if (!string.IsNullOrEmpty(searchDto.UserID) && searchDto.DaysOld > 0) { var _daysOld = DateTime.UtcNow.AddDays(-searchDto.DaysOld); projects = projects.Where(p => p.ModifiedDateTime > _daysOld); } var projectList = projects.ToList().OrderByDescending(p => p.ModifiedDateTime) .Select(project => new DashboardProjectDetailDto { ID = project.ID, CreatedDateTime = String.Format("{0:g}", project.CreatedDateTime), ModifiedDateTime = String.Format("{0:g}", project.ModifiedDateTime), ProjectName = project.ProjectName }); if (projects.Count() == 0 && string.IsNullOrEmpty(searchDto.ProjectName)) { return(new List <DashboardProjectDetailDto>()); } else if (projectList.Count() == 0) { throw new PowerDesignProException("ProjectNotFound", Message.ProjectDashboard); } return(projectList); }
private IEnumerable <SolutionHeaderDetailsInProjectDto> SharedProjectSolutionDetail(SearchProjectRequestDto projectRequestDto, string userName) { var sharedProject = _sharedProjectRepository.GetSingle(sp => sp.ProjectID == projectRequestDto.ID && sp.RecipientEmail.Equals(userName) && sp.Active); //var project = _projectRepository.GetSingle(p => p.Active && p.ID == projectRequestDto.ID); if (sharedProject == null) { throw new PowerDesignProException("ProjectNotFound", Message.ProjectDashboard); } var sharedProjectSolutionList = sharedProject.SharedProjectSolution.OrderByDescending(s => s.ModifiedDateTime) .Select(sharedSolution => { var sharedSolutionDetail = _solutionEntityToSolutionHeaderDetailsDtoMapper.AddMap(sharedSolution.Solution); sharedSolutionDetail.IsReadOnlyAccess = true; return(sharedSolutionDetail); }).ToList(); var copiedSolutionList = sharedProject.Project.Solutions.Where(x => userName.Equals(x.OwnedBy, StringComparison.InvariantCultureIgnoreCase) && x.Active); foreach (var item in copiedSolutionList) { var solution = _solutionEntityToSolutionHeaderDetailsDtoMapper.AddMap(item); sharedProjectSolutionList.Add(solution); } //.Select(copySolution => //{ // return _solutionEntityToSolutionHeaderDetailsDtoMapper.AddMap(copySolution); //}).ToList(); if (sharedProjectSolutionList == null || sharedProjectSolutionList.Count() == 0) { throw new PowerDesignProException("SolutionNotFound", Message.ProjectSolution); } //sharedProjectSolutionList.ToList().AddRange(copiedSolutionList); return(sharedProjectSolutionList.OrderByDescending(x => Convert.ToDateTime(x.ModifiedDateTime))); }
/// <summary> /// Gets the solution header details in project. /// </summary> /// <param name="projectRequestDto">The project request dto.</param> /// <returns></returns> /// <exception cref="PowerDesignProException"> /// ProjectNotFound /// or /// SolutionNotFound /// or /// ProjectNotFound /// </exception> public IEnumerable <SolutionHeaderDetailsInProjectDto> GetSolutionHeaderDetailsInProject(SearchProjectRequestDto projectRequestDto, string userName) { if (!string.IsNullOrEmpty(projectRequestDto.UserID) && projectRequestDto.ID > 0) { var projectDetail = _projectRepository.GetSingle(p => p.Active && p.UserID == projectRequestDto.UserID && p.ID == projectRequestDto.ID); if (projectDetail == null) { return(SharedProjectSolutionDetail(projectRequestDto, userName)); throw new PowerDesignProException("ProjectNotFound", Message.ProjectDashboard); } var solutionList = projectDetail.Solutions.Where(x => x.Active && userName.Equals(x.OwnedBy, StringComparison.InvariantCultureIgnoreCase)).OrderByDescending(s => s.ModifiedDateTime) .Select(solution => { var solutionDetail = _solutionEntityToSolutionHeaderDetailsDtoMapper.AddMap(solution); solutionDetail.IsReadOnlyAccess = false; return(solutionDetail); }); if (solutionList == null || solutionList.Count() == 0) { return(new List <SolutionHeaderDetailsInProjectDto>()); } return(solutionList); } throw new PowerDesignProException("ProjectNotFound", Message.ProjectDashboard); }