public List <IDomainObject> VratiListu(SqlDataReader reader) { try { List <IDomainObject> porudzbine = new List <IDomainObject>(); while (reader.Read()) { Porudzbina porudzbina = new Porudzbina { Id = (long)reader[0], Datum = (DateTime)reader[1], Klijent = new Klijent() { Id = (long)reader[3], NazivKompanije = reader[4].ToString() }, NacinIsporuke = new NacinIsporuke() { Id = (long)reader[5], NazivIsporuke = reader[6].ToString() }, NacinPlacanja = new NacinPlacanja() { Id = (long)reader[7], NazivPlacanja = reader[8].ToString() }, Katalog = new Katalog() { Id = (long)reader[9] } }; if (reader[2] == DBNull.Value) { porudzbina.UsloviIsporuke = null; } else { porudzbina.UsloviIsporuke = reader[2].ToString(); } porudzbine.Add(porudzbina); } return(porudzbine); } catch (Exception) { return(null); } }
public IDomainObject VratiObjekat(SqlDataReader reader) { try { Porudzbina porudzbina = new Porudzbina(); while (reader.Read()) { porudzbina.Id = (long)reader[0]; porudzbina.Datum = (DateTime)reader[1]; porudzbina.Klijent = new Klijent() { Id = (long)reader[3], NazivKompanije = reader[4].ToString() }; porudzbina.NacinIsporuke = new NacinIsporuke() { Id = (long)reader[5], NazivIsporuke = reader[6].ToString() }; porudzbina.NacinPlacanja = new NacinPlacanja() { Id = (long)reader[7], NazivPlacanja = reader[8].ToString() }; porudzbina.Katalog = new Katalog() { Id = (long)reader[9] }; if (reader[2] == DBNull.Value) { porudzbina.UsloviIsporuke = null; } else { porudzbina.UsloviIsporuke = reader[2].ToString(); } break; } return(porudzbina); } catch (Exception) { return(null); } }