コード例 #1
0
ファイル: RepositoriesDB.cs プロジェクト: ErnadJ/Homepage
 public RepositoriesDB()
 {
     _sqlManager        = new SQL();
     _listProjects      = new ListProjects();
     _listSkills        = new ListSkills();
     _listProjectImages = new ListProjectImages();
 }
コード例 #2
0
ファイル: RepositoriesDB.cs プロジェクト: ErnadJ/Homepage
        /** Methode gibt Skills Tabelle zurück als Liste **/
        private List <ListSkills> getSkills()
        {
            List <ListSkills> listSkills = new List <ListSkills>();

            DataTable currentSkillsTable = new DataTable();

            string sqlQuery = "";

            try
            {
                sqlQuery = "GetSkills";

                /** SQL Select Statement gibt die Tabelle "Skills" zurück **/
                currentSkillsTable = _sqlManager.ExecuteSelect(sqlQuery, new string[] { }, new object[] { });

                /** Tabelle wird in einer Schleife durchlaufen und ins Modell geladen
                 * und anschließend zur Liste "listSkills" hinzugefügt **/
                if (currentSkillsTable.Rows.Count > 0)
                {
                    for (int i = 0; i < currentSkillsTable.Rows.Count; i++)
                    {
                        ListSkills currentSkill = new ListSkills();

                        currentSkill.Id           = Convert.ToInt64(currentSkillsTable.Rows[i]["ID"]);
                        currentSkill.Name         = currentSkillsTable.Rows[i]["Name"].ToString();
                        currentSkill.CodeSnippet  = currentSkillsTable.Rows[i]["CodeSnippet"].ToString();
                        currentSkill.Value        = Convert.ToInt32(currentSkillsTable.Rows[i]["Value"]);
                        currentSkill.Active       = (bool)currentSkillsTable.Rows[i]["Active"];
                        currentSkill.CreationDate = (DateTime)currentSkillsTable.Rows[i]["CreationDate"];

                        listSkills.Add(currentSkill);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(listSkills);
        }