예제 #1
0
파일: Project.cs 프로젝트: LazyBui/Peygir
        public static Project GetProject(IDatabaseProvider db, int id)
        {
            if (db == null)
            {
                throw new ArgumentNullException(nameof(db));
            }
            ProjectsTableAdapter tableAdapter = db.DB.ProjectsTableAdapter;

            PeygirDatabaseDataSet.ProjectsDataTable rows = tableAdapter.GetDataByID(id);

            if (rows.Count == 1)
            {
                // Found.
                Project project = new Project(rows[0]);
                return(project);
            }

            // Not found.
            return(null);
        }
예제 #2
0
파일: Project.cs 프로젝트: LazyBui/Peygir
        public static Project[] GetProjects(IDatabaseProvider db)
        {
            if (db == null)
            {
                throw new ArgumentNullException(nameof(db));
            }
            ProjectsTableAdapter tableAdapter = db.DB.ProjectsTableAdapter;

            PeygirDatabaseDataSet.ProjectsDataTable rows = tableAdapter.GetData();

            // Create list.
            List <Project> projects = new List <Project>();

            foreach (var row in rows)
            {
                // Add.
                Project project = new Project(row);
                projects.Add(project);
            }

            return(projects.ToArray());
        }