public async Task <SensorsFromUser> CreateSensorAsync(string name, string description, string type, string latitude, string longitude, bool alarm, bool isPublic, string UserId, string ApiId, DateTime TimeStamp) { var sensorToAdd = new SensorsFromUser() { Name = name, Description = description, MeasurmentType = type, Latitude = latitude, Longitude = longitude, Alarm = alarm, IsPublic = isPublic, UserId = UserId, ApiId = ApiId, TimeStamp = DateTime.Now.ToString("O")//"yyyy-MM-ddTHH:mm:ss.FFFFFFF" }; var test = sensorRepo.All().Where(s => ApiId == s.ApiId).ToList(); var test2 = sensorRepo.All().ToList(); sensorToAdd.PoolInterval = apiSensorRepo.All().Where(s => ApiId == s.ApiId).Select(s => s.PoolInterval).FirstOrDefault(); sensorToAdd.MeasurmentType = apiSensorRepo.All().Where(s => ApiId == s.ApiId).Select(s => s.MeasurmentType).FirstOrDefault(); sensorToAdd.ValueRangeMin = apiSensorRepo.All().Where(s => ApiId == s.ApiId).Select(s => s.ValueRangeMin).FirstOrDefault(); sensorToAdd.ValueRangeMax = apiSensorRepo.All().Where(s => ApiId == s.ApiId).Select(s => s.ValueRangeMax).FirstOrDefault(); await sensorRepo.AddAsync(sensorToAdd); await sensorRepo.SaveAsync(); return(sensorToAdd); }
public SensorDetailsViewModel(SensorsFromUser sensor) { this.ID = sensor.ID; this.Name = sensor.Name; this.Description = sensor.Description; this.Value = sensor.Value; this.Latitude = sensor.Latitude; this.Longitude = sensor.Longitude; this.Alarm = sensor.Alarm; this.IsPublic = sensor.IsPublic; this.ValueRangeMin = sensor.ValueRangeMin; this.ValueRangeMax = sensor.ValueRangeMax; this.PollingInterval = sensor.PoolInterval; }
public SensorViewModel(SensorsFromUser sensor) { this.ID = ID; this.Name = Name; this.Description = Description; this.PollingIntervalInSeconds = PollingIntervalInSeconds; this.URL = URL; this.Type = Type; this.Latitude = Latitude; this.Longitude = Longitude; this.Alarm = Alarm; this.IsPublic = IsPublic; this.ApiId = ApiId; this.ValueRangeMin = ValueRangeMin; this.ValueRangeMax = ValueRangeMax; this.TimeStamp = DateTime.Now; this.UserId = UserId; }
public void Delete(SensorsFromUser entity) { sensorRepo.Delete(entity); sensorRepo.Save(); }
public void UpdateSensor(SensorsFromUser editedSensor) { sensorRepo.Update(editedSensor); sensorRepo.Save(); }