Ejemplo n.º 1
0
        public Nabidka Read(int id)
        {
            UzivatelDao   dao  = new UzivatelDao();
            Nabidka       n    = null;
            SqlConnection conn = DatabaseConnection.GetInstance();

            using (SqlCommand command = new SqlCommand("SELECT * FROM nabidka WHERE id = @Id", conn))
            {
                SqlParameter param = new SqlParameter();
                param.ParameterName = "@Id";
                param.Value         = id;

                command.Parameters.Add(param);
                SqlDataReader reader = command.ExecuteReader();

                while (reader.Read())
                {
                    n = new Nabidka(
                        castka: Int32.Parse(reader[1].ToString()),
                        prihazujici: dao.GetById(Int32.Parse(reader[2].ToString())));
                    n.ID = Int32.Parse(reader[0].ToString());
                }
                reader.Close();
                return(n);
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Metoda vyuziva tridu UzivatelDAO a jeji metodu GetById
 /// Pokud jeste uzivatel neni v cache tak se dotaze a nasledne ulozi do cache
 /// </summary>
 /// <param name="id">Id uzivatele ktereho hledame</param>
 /// <returns>Vraci ziskaneho uzivatele, nebo uzivatele ktery uz je ulozen v cache</returns>
 public Uzivatel GetById(int id)
 {
     if (!uzivatele.ContainsKey(id))
     {
         uzivatele[id] = dao.GetById(id);
     }
     return(uzivatele[id]);
 }