/// <summary> /// Gets all categories in database /// </summary> /// <returns>List of categories</returns> public override List<Res> FillRess() { List<Res> infos = new List<Res>(); 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 ResID,FileName,ResType,Description,Author,IsPublished,DateCreated,Points " + "FROM " + tablePrefix + "Res "; cmd.CommandText = sqlQuery; cmd.CommandType = CommandType.Text; conn.Open(); using (DbDataReader rdr = cmd.ExecuteReader()) { if (rdr.HasRows) { while (rdr.Read()) { Res inf = new Res(); inf.Id = new Guid(rdr.GetGuid(0).ToString()); inf.FileName = rdr.GetString(1); inf.ResType = rdr.GetString(2); inf.Description = rdr.GetString(3); inf.Author = rdr.GetString(4); inf.IsPublished = rdr.GetBoolean(5); inf.DateCreated = rdr.GetDateTime(6); inf.Points = rdr.GetInt32(7); 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 Res SelectRes(Guid id) { List<Res> Ress = Res.Ress; Res res = new Res(); foreach (Res cat in Ress) { if (cat.Id == id) res = cat; } res.MarkOld(); return res; }