public int UpdateDeonica(int id, Deonica r) { try { ISession s = DataLayer.GetSession(); IQuery query = s.CreateQuery("select r from Deonica r where r.IdDeonice = " + id); Deonica deonica = query.UniqueResult <Deonica>(); deonica.KrajnjiGrad = r.KrajnjiGrad; deonica.PocetniGrad = r.PocetniGrad; deonica.PocetniKilometar = r.PocetniKilometar; deonica.ZavrsniKilometar = r.ZavrsniKilometar; s.SaveOrUpdate(deonica); s.Flush(); s.Close(); return(1); } catch (Exception exc) { System.Windows.Forms.MessageBox.Show(exc.Message); return(-1); } }
public DeonicaView GetDeonica(int id) { ISession s = DataLayer.GetSession(); Deonica deonica = s.Query <Deonica>().Where(e => e.IdDeonice == id).Select(p => p).FirstOrDefault(); DeonicaView d = new DeonicaView(deonica); return(d); }
//public int IdGradilista { get; set; } public DeonicaView(Deonica d) { this.IdDeonice = d.IdDeonice; this.KrajnjiGrad = d.KrajnjiGrad; this.PocetniGrad = d.PocetniGrad; this.PocetniKilometar = d.PocetniKilometar; this.ZavrsniKilometar = d.ZavrsniKilometar; //this.IdGradilista = d.Gradiliste.IdGradilista; }
public int AddDeonica(Deonica v) { try { ISession s = DataLayer.GetSession(); s.Save(v); s.Flush(); s.Close(); return(1); } catch (Exception e) { return(-1); } }
public int RemoveDeonica(int id) { try { ISession s = DataLayer.GetSession(); Deonica n = s.Load <Deonica>(id); s.Delete(n); s.Flush(); s.Close(); return(1); } catch (Exception e) { return(-1); } }
private void btnVratiAngazovaneIzvrsioce_Click(object sender, EventArgs e) { try { ISession s = DataLayer.GetSession(); Deonica d = s.Load <Deonica>(3); foreach (Izvrsilac j in d.Izvrsioci) { MessageBox.Show(j.Ime); } s.Close(); } catch (Exception ec) { MessageBox.Show(ec.Message); } }
private void btnAngazovanjaTer_Click(object sender, EventArgs e) { try { ISession s = DataLayer.GetSession(); Deonica d = s.Load <Deonica>(1); foreach (RadnaMasina ra in d.RadneMasine) { MessageBox.Show("Tip radne masine: " + ra.Tip); } foreach (Teretno t in d.Teretna) { MessageBox.Show("Nosivost teretnog vozila: " + t.Nosivost.ToString()); } s.Close(); } catch (Exception ec) { MessageBox.Show(ec.Message); } }
// PUT api/deonica/5 public int Put(int id, [FromBody] Deonica value) { DataProvider provider = new DataProvider(); return(provider.UpdateDeonica(id, value)); }
// POST api/deonica public int Post([FromBody] Deonica value) { DataProvider dp = new DataProvider(); return(dp.AddDeonica(value)); }