Exemple #1
0
        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);
        }
Exemple #2
0
        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());
        }