public static List <WorkflowModel> GetCoachWorkflows(int coachId) { List <Project> projects = ProjectUtil.GetCoachProjects(coachId); List <WorkflowModel> workflowList = new List <WorkflowModel>(); foreach (Project proj in projects) { string query = "SELECT WorkflowID, WorkflowName from Workflows WHERE WorkflowID = @workflowId"; MySqlCommand cmd = new MySqlCommand(query); cmd.Parameters.AddWithValue("@workflowId", proj.WorkflowId); DBConn conn = new DBConn(); MySqlDataReader dr = conn.ExecuteSelectCommand(cmd); while (dr.Read()) { WorkflowModel w = new WorkflowModel((int)dr["WorkflowID"], (string)dr["WorkflowName"]); workflowList.Add(w); } conn.CloseConnection(); } workflowList = workflowList.GroupBy(p => p.WorkflowId).Select(g => g.First()).ToList(); return(workflowList); }
public static List <Form> GetCoachForms(int coachId) { List <Project> projects = ProjectUtil.GetCoachProjects(coachId); List <Form> formList = new List <Form>(); foreach (Project p in projects) { MySqlCommand cmd = new MySqlCommand("SELECT FormID, FormTemplateID, FormName, FormData, ProjectID, ApprovalRequiredID, ApprovalStatusID, Submission, Approved, Denied, DenialReason FROM Forms WHERE ProjectId = @projId"); cmd.Parameters.AddWithValue("@projId", p.ProjectId); DBConn conn = new DBConn(); MySqlDataReader dr = conn.ExecuteSelectCommand(cmd); try { while (dr.Read()) { Form f = new Form((int)dr["FormID"], (string)dr["FormName"], (string)dr["FormData"], p.ProjectId, (int)dr["Submission"], (string)dr["Approved"], (string)dr["Denied"], (string)dr["DenialReason"], (int)dr["FormTemplateID"]); formList.Add(f); } } catch (Exception e) { } conn.CloseConnection(); } return(formList); }