Exemplo n.º 1
0
 public void SaveOrUpdate <T>(T t, int id) where T : class
 {
     using (FLMSEntities entities = new FLMSEntities())
     {
         if (id == 0)
         {
             entities.Set <T>().Add(t);
             entities.SaveChanges();
         }
         else
         {
             entities.Entry(t).State = EntityState.Modified;
             entities.SaveChanges();
         }
     }
 }
Exemplo n.º 2
0
 public void SaveOrUpdate(City city)
 {
     using (FLMSEntities entities = new FLMSEntities())
     {
         if (city.Id == 0)
         {
             entities.Cities.Add(city);
             entities.SaveChanges();
         }
         else
         {
             entities.Entry(city).State = System.Data.Entity.EntityState.Modified;
             entities.SaveChanges();
         }
     }
 }
 public void SaveOrUpdate(SensorDevice district)
 {
     using (FLMSEntities entities = new FLMSEntities())
     {
         if (district.Id == 0)
         {
             entities.SensorDevices.Add(district);
             entities.SaveChanges();
         }
         else
         {
             entities.Entry(district).State = System.Data.Entity.EntityState.Modified;
             entities.SaveChanges();
         }
     }
 }
Exemplo n.º 4
0
 public void SaveOrUpdate(Tank tank)
 {
     using (FLMSEntities entities = new FLMSEntities())
     {
         if (tank.Id == 0)
         {
             entities.Tanks.Add(tank);
             entities.SaveChanges();
         }
         else
         {
             entities.Entry(tank).State = System.Data.Entity.EntityState.Modified;
             entities.SaveChanges();
         }
     }
 }
Exemplo n.º 5
0
 public void SaveOrUpdate(Geolocation geolocation)
 {
     using (FLMSEntities entities = new FLMSEntities())
     {
         if (geolocation.Id == 0)
         {
             entities.Geolocations.Add(geolocation);
             entities.SaveChanges();
         }
         else
         {
             entities.Entry(geolocation).State = System.Data.Entity.EntityState.Modified;
             entities.SaveChanges();
         }
     }
 }
 public void SaveOrUpdate(Depot depots)
 {
     using (FLMSEntities entities = new FLMSEntities())
     {
         if (depots.Id == 0)
         {
             entities.Depots.Add(depots);
             entities.SaveChanges();
         }
         else
         {
             entities.Entry(depots).State = System.Data.Entity.EntityState.Modified;
             entities.SaveChanges();
         }
     }
 }