public IActionResult Create(long?id) { var model = new DeviceSensorSettings(); if (id.HasValue) { model = Repository.Get(id.Value); } return(View(model)); }
public RedirectResult Create(DeviceSensorSettings sensorSettings) { if (Repository.Get(sensorSettings.Id) != null) { var update = Repository.Get(sensorSettings.Id); update.CopyDataFrom(sensorSettings); Repository.Put(update.Id, update); return(Redirect("/DeviceSensorSettings")); } Repository.Post(sensorSettings); return(Redirect("/DeviceSensorSettings")); }
public RedirectResult ChangeSettings(DeviceSensorSettings sensorSettings)//(bool isEnabled, string startTime, string endTime) { var settings = Repository.GetAll(); if (settings.Count <= 0) { return(Redirect("/DeviceSensorSettings")); } var setting = Repository.Get(settings[0].Id); setting.CopySettings(sensorSettings); Repository.Put(setting.Id, setting); return(Redirect("/DeviceSensorSettings")); }