public static List <Project> GetAllProjects() { string query = $"SELECT p.*,u.* FROM managertasks.project p join user u on u.id=p.managerId"; Func <MySqlDataReader, List <Project> > func = (reader) => { List <Project> projects = new List <Project>(); while (reader.Read()) { projects.Add(ConvertProject.convertDBtoProjectsWithManager(reader)); } return(projects); }; return(DBAccess.RunReader(query, func)); }
/// <summary> /// Gets all projects /// </summary> /// <returns>List<Project> all projects</returns> public static List <Project> GetAllProjects() { string query = $"SELECT p.*,u.* FROM managertasks.project p join user u on u.id=p.managerId"; Func <MySqlDataReader, List <Project> > func = (reader) => { List <Project> projects = new List <Project>(); while (reader.Read()) { projects.Add(ConvertProject.convertDBtoProjectsWithManager(reader)); } return(projects); }; List <Project> allProjects = DBAccess.RunReader(query, func); allProjects.ForEach(p => { p.HoursForDepartment = GetHoursDepartmentsProject(p.ProjectId); }); return(allProjects); }