public List <ReportModel> GetReportsListByUser(int projectId, UserModel loggedinUser) { log.Debug(MethodHelper.GetCurrentMethodName() + " Method execution start."); try { using (ProjectDB projectDB = new ProjectDB()) { var projectMapping = projectDB.GetProjectMappingByUser(projectId, loggedinUser.Pfid); // If no mapping found then user is not assigned the project. if (projectMapping == null) { return(null); } // If user is project admin, then return all reports, else return reports assigned to user. if (projectMapping.IsProjectAdmin == 1) { return(projectDB.GetReportsByProject(projectId).Where(p => p.IsActive == 1).ToList()); } return(projectDB.GetReportMappingByUser(projectId, loggedinUser.Pfid)); } } catch (Exception exception) { errorLog.Fatal("Exception " + exception.Message + "\n" + exception.StackTrace); throw; } finally { log.Debug(MethodHelper.GetCurrentMethodName() + " Method execution end."); } }
public bool IsProjectAssignedToUser(int projectId, int pfid, out ProjectMappingModel projectMapping) { log.Debug(MethodHelper.GetCurrentMethodName() + " Method execution start."); try { using (ProjectDB projectDB = new ProjectDB()) { projectMapping = projectDB.GetProjectMappingByUser(projectId, pfid); } return(projectMapping != null); } catch (Exception exception) { errorLog.Fatal("Exception " + exception.Message + "\n" + exception.StackTrace); throw; } finally { log.Debug(MethodHelper.GetCurrentMethodName() + " Method execution end."); } }