public void Delete(int id) { using (IrigationDBEntities1 context = new IrigationDBEntities1()) { Senzori senzor = context.Senzoris.FirstOrDefault(s => s.Id == id); context.Senzoris.Remove(senzor); context.SaveChanges(); } }
public void Put(Senzori sen) { using (IrigationDBEntities1 context = new IrigationDBEntities1()) { Senzori senzor = context.Senzoris.FirstOrDefault(s => s.Id == sen.Id); senzor.Locatie = sen.Locatie; context.SaveChanges(); } }
public Senzori Post(Senzori senzor) { using (IrigationDBEntities1 context = new IrigationDBEntities1()) { // value.Senzori = context.Senzoris.Include(sen => sen.Values).Include(sen => sen.Istorics).Where(sen => sen.Id == value.Id_senzor).First(); context.Senzoris.Add(senzor); context.SaveChanges(); } return(senzor); }
public Senzori Get(int id) { using (IrigationDBEntities1 context = new IrigationDBEntities1()) { //var jsonString = Newtonsoft.Json.JsonConvert.SerializeObject(obj); // var s = context.Senzoris.Where(sen => sen.Id == id).First(); Senzori s = context.Senzoris.Include(sen => sen.Values).Include(sen => sen.Istorics).Where(sen => sen.Id == id).First(); return(s); } }