/// <summary> /// Gets header level details for the solution /// </summary> /// <param name="userID"></param> /// <param name="projectID"></param> /// <param name="solutionID"></param> /// <param name="username"></param> /// <returns></returns> public SolutionHeaderDetailDto GetSolutionHeaderDetails(string userID, int projectID, int solutionID, string userName) { var projectDetail = _projectRepository.GetSingle(p => p.Active && p.UserID == userID && p.ID == projectID); if (projectDetail == null) { return(SharedProjectSolutionDetail(projectID, solutionID, userName)); throw new PowerDesignProException("ProjectNotFound", Message.ProjectDashboard); } var projectSolutionDetail = projectDetail.Solutions.Where(x => x.Active && x.ID == solutionID) .Select(solution => { var solutionDetail = new SolutionHeaderDetailDto { ProjectID = projectID, SolutionID = solution.ID, SolutionName = solution.SolutionName, IsReadOnlyAccess = false, ShowGrantAccess = !solution.CreatedBy.Equals(solution.Project.CreatedBy, StringComparison.InvariantCultureIgnoreCase) }; return(solutionDetail); }).FirstOrDefault(); if (projectSolutionDetail == null) { throw new PowerDesignProException("SolutionNotFound", Message.ProjectSolution); } return(projectSolutionDetail); throw new PowerDesignProException("ProjectNotFound", Message.ProjectDashboard); }
private SolutionHeaderDetailDto SharedProjectSolutionDetail(int projectID, int solutionID, string userName) { var sharedProject = _sharedProjectRepository.GetSingle(sp => sp.ProjectID == projectID && sp.RecipientEmail.Equals(userName)); var project = _projectRepository.GetSingle(p => p.Active && p.ID == projectID); if (sharedProject == null) { throw new PowerDesignProException("ProjectNotFound", Message.ProjectDashboard); } var sharedProjectSolution = project.Solutions.Where(x => x.Active && x.ID == solutionID) .Select(solution => { var readOnlyAccess = false; if (!string.IsNullOrEmpty(solution.OwnedBy)) { if (!solution.OwnedBy.Equals(userName, StringComparison.InvariantCultureIgnoreCase)) { readOnlyAccess = true; } else { readOnlyAccess = false; } } else { readOnlyAccess = true; } var solutionDetail = new SolutionHeaderDetailDto { ProjectID = projectID, SolutionID = solution.ID, SolutionName = solution.SolutionName, IsReadOnlyAccess = readOnlyAccess, ShowGrantAccess = !readOnlyAccess && !solution.CreatedBy.Equals(solution.Project.CreatedBy, StringComparison.InvariantCultureIgnoreCase) }; return(solutionDetail); }).FirstOrDefault(); if (sharedProjectSolution == null) { throw new PowerDesignProException("SolutionNotFound", Message.ProjectSolution); } return(sharedProjectSolution); }