public static List <AlarmniSistemView> VratiSveALarmneSistemeObjekat(int id) { var alarmi = new List <AlarmniSistemView>(); try { ISession s = DataLayer.GetSession(); var sviAlarmi = from o in s.Query <AlarmniSistem>() where o.Objekat.ObjekatId == id select o; foreach (AlarmniSistem a in sviAlarmi) { AlarmniSistemView a1 = new AlarmniSistemView(a); a1.Zaduzen = a.Zaduzeni.Select(a => new ZaduzenView(a)).ToList(); a1.Objekat = new ObjekatView(a.Objekat); alarmi.Add(a1); } s.Close(); } catch (Exception e) { Console.WriteLine(e); throw; } return(alarmi); }
public static List <AlarmniSistemView> VratiSveAlarmneSisteme() { List <AlarmniSistemView> alarmi = new List <AlarmniSistemView>(); try { ISession s = DataLayer.GetSession(); IEnumerable <AlarmniSistem> sviAlarmi = from a in s.Query <AlarmniSistem>() select a; foreach (AlarmniSistem a in sviAlarmi) { AlarmniSistemView tmp = new AlarmniSistemView(a); tmp.Objekat = new ObjekatView(a.Objekat); tmp.Zaduzen = a.Zaduzeni.Select(z => new ZaduzenView(z)).ToList(); alarmi.Add(tmp); } s.Close(); } catch (Exception e) { Console.WriteLine(e); throw; } return(alarmi); }