public List <ReleaseManagementModel> GetAllCompletedModules(string userName) { List <ReleaseManagementModel> comlpetedModules = new List <ReleaseManagementModel>(); DataSet dsGetprojectId = dal.GetProjectId(userName); List <ReleaseManagementModel> projects = new List <ReleaseManagementModel>(); ReleaseManagementModel project; foreach (DataRow row in dsGetprojectId.Tables[0].Rows) { project = new ReleaseManagementModel(); project.ProjectId = row[0].ToString(); project.ProjectName = row[0].ToString(); projects.Add(project); } DataSet dsGetAllCompletedModules; ReleaseManagementModel modules; for (int i = 0; i < projects.Count; i++) { dsGetAllCompletedModules = dal.GetAllCompletedModules(projects[i].ProjectId); foreach (DataRow row in dsGetAllCompletedModules.Tables[0].Rows) { modules = new ReleaseManagementModel(); modules.ProjectName = row[0].ToString(); modules.ModuleName = row[1].ToString(); modules.ModuleStatus = row[2].ToString(); modules.ModuleId = row[3].ToString(); comlpetedModules.Add(modules); } } DataSet dsGetAllDeveloperName = dal.GetAllDeveloperName(); DataSet dsGetAllTesterName = dal.GetAllTesterName(); List <ReleaseManagementModel> developerList = new List <ReleaseManagementModel>(); ReleaseManagementModel developer; foreach (DataRow row in dsGetAllDeveloperName.Tables[0].Rows) { developer = new ReleaseManagementModel(); developer.DeveloperName = row[0].ToString(); developer.ModuleId = row[1].ToString(); developerList.Add(developer); } List <ReleaseManagementModel> testerList = new List <ReleaseManagementModel>(); ReleaseManagementModel tester; foreach (DataRow row in dsGetAllTesterName.Tables[0].Rows) { tester = new ReleaseManagementModel(); tester.TesterName = row[0].ToString(); tester.ModuleId = row[1].ToString(); testerList.Add(tester); } for (int i = 0; i < developerList.Count; i++) { for (int j = 0; j < comlpetedModules.Count; j++) { if (developerList[i].ModuleId == comlpetedModules[j].ModuleId) { comlpetedModules[j].DeveloperName = developerList[i].DeveloperName; } } } for (int i = 0; i < testerList.Count; i++) { for (int j = 0; j < comlpetedModules.Count; j++) { if (testerList[i].ModuleId == comlpetedModules[j].ModuleId) { comlpetedModules[j].TesterName = testerList[i].TesterName; } } } return(comlpetedModules); }