public static List <Model.Fajl> getSlike(string idPost) { string cs = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString; SqlConnection conn = null; SqlDataReader reader = null; try { conn = new SqlConnection(cs); SqlCommand com = new SqlCommand("DetaljnijeSlike", conn); com.CommandType = CommandType.StoredProcedure; com.Parameters.AddWithValue("@idPost", idPost); conn.Open(); reader = com.ExecuteReader(); List <Model.Fajl> slike = new List <Model.Fajl>(); while (reader.Read()) { Model.Fajl slika = new Model.Fajl(); slika.Datum = DateTime.Parse(reader["Datum"].ToString()); slika.Putanja = reader["Putanja"].ToString(); slika.OpisFajla = reader["OpisFajla"].ToString(); slike.Add(slika); } return(slike); } catch (Exception exp) { HttpContext.Current.Trace.Warn("Greška", "Greška getSlike(string idPost)", exp); } finally { if (reader != null) { reader.Close(); } if (conn != null && conn.State != ConnectionState.Closed) { conn.Close(); } } return(null); }
public static Model.Fajl getSlikaMojNalog(string korisnik) { string cs = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString; SqlConnection conn = null; SqlDataReader reader = null; try { conn = new SqlConnection(cs); SqlCommand com = new SqlCommand("MojNalog", conn); com.CommandType = CommandType.StoredProcedure; com.Parameters.AddWithValue("@UserName", korisnik); conn.Open(); reader = com.ExecuteReader(); Model.Fajl slika = new Model.Fajl(); reader.Read(); slika.Putanja = reader["Putanja"].ToString(); return(slika); } catch (Exception exp) { HttpContext.Current.Trace.Warn("Greška", "Greška getSlikaMojNalog(string korisnik)", exp); } finally { if (reader != null) { reader.Close(); } if (conn != null && conn.State != ConnectionState.Closed) { conn.Close(); } } return(null); }