Exemplo n.º 1
0
 public SensorEditViewModel(UserSensors userSensors, SensorValidationsViewModel sensorValidations)
 {
     this.Id                     = userSensors.Id;
     this.UserId                 = userSensors.UserId;
     this.SensorId               = userSensors.SensorId;
     this.MinValue               = userSensors.UserMinValue;
     this.MaxValue               = userSensors.UserMaxValue;
     this.UserMaxValue           = userSensors.UserMaxValue.ToString();
     this.UpdateInterval         = userSensors.UpdateInterval;
     this.Name                   = userSensors.Name;
     this.Description            = userSensors.Description;
     this.IsPublic               = userSensors.IsPublic;
     this.IsRequiredNotification = userSensors.IsRequiredNotification;
     this.Latitude               = userSensors.Latitude;
     this.Longitude              = userSensors.Longitude;
     this.SensorValidations      = sensorValidations;
     this.TypeId                 = userSensors.Type;
     if (userSensors.Type == 4)
     {
         this.UserMinValue = userSensors.UserMinValue.ToString();
     }
 }
Exemplo n.º 2
0
        public async Task <IActionResult> Edit(int id)
        {
            try
            {
                var sensor = await _userSensorService.FindAsync(id);

                var sensorType = _sensorService.Find(sensor.SensorId);

                if (sensor == null)
                {
                    throw new ApplicationException($"Unable to find sensor with ID '{id}'.");
                }
                var sensorValidation = new SensorValidationsViewModel(sensorType);

                var model = new SensorDetailsViewModel(sensor, sensorValidation);

                return(View(model));
            }
            catch
            {
                return(View("PageNotFound"));
            }
        }