public List <ProjectDepartmentDTO> GetProjectDepartmentDTO() { ProjectDAO dao = new ProjectDAO(); DepartmentDAO depdao = new DepartmentDAO(); List <Project> projectsModel = dao.GetAll(); List <ProjectDepartmentDTO> projDepDTO = new List <ProjectDepartmentDTO>(); List <string> mutualFileds = typeof(Project).GetProperties().Select(p => p.Name) .Intersect(typeof(ProjectDepartmentDTO).GetProperties().Select(p => p.Name)).ToList(); for (int i = 0; i < projectsModel.Count; i++) { // Add new Element projDepDTO.Add(new ProjectDepartmentDTO()); // Fill mutual fields foreach (string f in mutualFileds) { typeof(ProjectDepartmentDTO).GetProperty(f).SetValue(projDepDTO[i], typeof(Project).GetProperty(f).GetValue(projectsModel[i])); } // Add Department projDepDTO[i].BelongsToDepartment = depdao.GetFiltered("id", projDepDTO[i].DepartmentID.ToString()); } return(projDepDTO); }
/// <summary> /// Return all the project /// </summary> private void GetAllProject() { ProjectDAO projectDAO = new ProjectDAO(); List <ProjectViewModel> project = projectDAO.GetAll(); foreach (var p in project) { listView1.Items.Add(p.ProjectId + "," + p.ProjectName); } }
public IHttpActionResult Get() { List <ProjectViewModel> list = projectDao.GetAll(); if (list.Count == 0) { return(NotFound()); } return(Ok(list)); }