예제 #1
0
 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();
     }
 }
예제 #2
0
 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();
     }
 }
예제 #3
0
 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);
 }
예제 #4
0
 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);
     }
 }