Exemplo n.º 1
0
 public IDomainObject VratiObjekat(SqlDataReader reader)
 {
     try
     {
         Cena cena = new Cena();
         while (reader.Read())
         {
             cena.Lajsna = new Lajsna()
             {
                 Id = (long)reader[3], NazivLajsne = reader[4].ToString()
             };
             cena.DatumOd = (DateTime)reader[0];
             cena.Iznos   = (int)reader[2];
             if (!string.IsNullOrEmpty(reader[1].ToString()))
             {
                 cena.DatumDo = (DateTime)reader[1];
             }
             else
             {
                 cena.DatumDo = null;
             }
             //cena.DatumDo = reader[2] == DBNull.Value ? null : Convert.ToDateTime(reader[2].ToString());
             break;
         }
         return(cena);
     }
     catch (Exception)
     {
         return(null);
     }
 }
Exemplo n.º 2
0
 public List <IDomainObject> VratiListu(SqlDataReader reader)
 {
     try
     {
         List <IDomainObject> cene = new List <IDomainObject>();
         while (reader.Read())
         {
             Cena cena = new Cena
             {
                 Lajsna = new Lajsna()
                 {
                     Id = (long)reader[3], NazivLajsne = reader[4].ToString()
                 },
                 DatumOd = (DateTime)reader[0],
                 Iznos   = (int)reader[2]
             };
             if (!string.IsNullOrEmpty(reader[1].ToString()))
             {
                 cena.DatumDo = (DateTime)reader[1];
             }
             else
             {
                 cena.DatumDo = null;
             }
             //cena.DatumDo = reader[2] == DBNull.Value ? null : Convert.ToDateTime(reader[2].ToString());
             cene.Add(cena);
         }
         return(cene);
     }
     catch (Exception)
     {
         return(null);
     }
 }