public List <Actuator_Action> AddNewSensorData(Sensor_Record sensorData) { List <Actuator_Action> listAction = new List <Actuator_Action>(); try { farmingContext.SensorRecords.Add(sensorData); farmingContext.SaveChanges(); // var period = PeriodDetail(sensorData.Farm_ComponentId); if (sensorData.Temperature != null) { listAction.Add(ActionForTemp(period, (double)sensorData.Temperature)); } if (sensorData.Luminosity != null) { listAction.Add(ActionForLight(period, (double)sensorData.Luminosity)); } if (sensorData.Soil_Humidity != null) { listAction.Add(ActionForSoilHum(period, (double)sensorData.Soil_Humidity)); } return(listAction); } catch { // actuator do nothing return(listAction); } }
public UserUpdateInfo UpdateUserInfo(UserUpdateInfo userInfo) { var user = this._context.Users.Where(data => data.UserId == userInfo.UserId).SingleOrDefault(); if (user != null) { user.Name = userInfo.Name; user.Address = userInfo.Address; user.DOB = userInfo.DOB; _context.Entry(user).State = EntityState.Modified; _context.SaveChanges(); return(new UserUpdateInfo { UserId = user.UserId, Name = user.Name, Address = user.Address, DOB = user.DOB }); } throw new Exception(); }
public void AddNewFarm(Farm farm) { _farmingContext.Farms.Add(farm); _farmingContext.SaveChanges(); }
public void AddNewPlant(PlantType plant) { _farmingContext.Plants.Add(plant); _farmingContext.SaveChanges(); }