public static void SacuvahHraniliste(HranilisteBasic a, int idOblasti) { try { ISession s = DataLayer.GetSession(); StalnaZastita o = s.Load <StalnaZastita>(idOblasti); Hraniliste h = new Hraniliste() { KrajnjiMesec = a.KrajnjiMesec, PocetniMesec = a.PocetniMesec }; o.Hranilista.Add(h); h.Oblast = o; s.Save(o); s.Flush(); s.Close(); } catch (Exception) { throw; } }
public static int DodajOblast(OblastBasic a) // ovo ne radi kako treba { try { ISession s = DataLayer.GetSession(); string ime = (from ob in s.Query <Oblast>() where (ob.JedinstvenoIme == a.JedinstvenoIme) select ob.JedinstvenoIme).SingleOrDefault(); if (ime == a.JedinstvenoIme) { return(0); } Oblast o = null; if (a.TipZastite == "Stalna zastita") { o = new StalnaZastita() { JedinstvenoIme = a.JedinstvenoIme, Povrsina = a.Povrsina }; } else if (a.TipZastite == "Monitoring") { o = new Monitoring() { JedinstvenoIme = a.JedinstvenoIme, Povrsina = a.Povrsina }; } else { o = new PovremeneIntervencije() { JedinstvenoIme = a.JedinstvenoIme, Povrsina = a.Povrsina }; } s.Save(o); s.Flush(); s.Close(); } catch (Exception ec) { return(2); } return(1); }