/// <summary> /// Gets all categories in database /// </summary> /// <returns>List of categories</returns> public override List<CurriculaInfo> FillCurriculaInfos() { List<CurriculaInfo> infos = new List<CurriculaInfo>(); string connString = ConfigurationManager.ConnectionStrings[connStringName].ConnectionString; string providerName = ConfigurationManager.ConnectionStrings[connStringName].ProviderName; DbProviderFactory provider = DbProviderFactories.GetFactory(providerName); using (DbConnection conn = provider.CreateConnection()) { conn.ConnectionString = connString; using (DbCommand cmd = conn.CreateCommand()) { string sqlQuery = "SELECT InfoID, CurriculaID,StartDate,EndDate,Cast,CityTown,IsPublished " + "FROM " + tablePrefix + "CurriculaInfo "; cmd.CommandText = sqlQuery; cmd.CommandType = CommandType.Text; conn.Open(); using (DbDataReader rdr = cmd.ExecuteReader()) { if (rdr.HasRows) { while (rdr.Read()) { CurriculaInfo inf = new CurriculaInfo(); inf.CurriculaId = rdr.GetGuid(1); inf.StartDate = rdr.GetDateTime(2); inf.EndDate = rdr.GetDateTime(3); inf.Cast = rdr.GetInt32(4); inf.CityTown = rdr.GetString(5); if (rdr.IsDBNull(6)) { inf.IsPublished = rdr.GetBoolean(6); } else { inf.IsPublished = false; } inf.Id = new Guid(rdr.GetGuid(0).ToString()); infos.Add(inf); inf.MarkOld(); } } } } } return infos; }
/// <summary> /// Returns a field /// </summary> /// <param name="id">Id of field to return</param> /// <returns></returns> public override CurriculaInfo SelectCurriculaInfo(Guid id) { List<CurriculaInfo> infos = CurriculaInfo.CurriculaInfos; CurriculaInfo info = new CurriculaInfo(); foreach (CurriculaInfo cat in infos) { if (cat.Id == id) info = cat; } info.MarkOld(); return info; }