public async Task EditAsync([NotNull] string id, [NotNull] DeviceEditModel model, [NotNull] string appId, [NotNull] string appKey) { var appInfo = new ElectOneSignalAppOption(appId, appKey); await EditAsync(id, model, appInfo); }
public ApplicationResult UpdateDevice(DeviceEditModel model) { var device = _deviceRepository.GetById(model.Id); if (device == null) { return(ApplicationResult.Fail("Device not found")); } Mapper.Map(model, device); _deviceRepository.Update(device); return(ApplicationResult.Ok()); }
public ActionResult Edit(int Id) { try { var cont = (iotContext)System.Web.HttpContext.Current.Session["iotcontext"]; Device dev = cont.Devices.First(d => d.Id == Id); DeviceEditModel model = new DeviceEditModel(dev, cont.Locations.ToList(), cont.Types.ToList()); return(View(model)); } catch (Exception e) { return(View()); } }
public async Task <ActionResult> Edit(DeviceEditModel model) { try { if (model.Device != null) { var provider = new DeviceProvider(DomainSession.GetDataContextForUserContext(this.HttpContext)); model.Result = StatusResponseGenerator.GetStatusResponseResultForReturnParam(provider.Update(model.Device)); return(View(model)); } else { model.Result = StatusResponseGenerator.GetAlertPanelWithMsgAndStat("Error.", RequestStatus.Failure); } } catch (Exception e) { model.Result = StatusResponseGenerator.GetAlertPanelWithMsgAndStat("Error.", RequestStatus.Failure); } return(View(model)); }
public async Task EditAsync([NotNull] string id, [NotNull] DeviceEditModel model, [NotNull] ElectOneSignalAppOption appInfo) { model.AppId = appInfo.AppId; try { await ElectOneSignalConstants.DefaultApiUrl .ConfigureRequest(config => { config.JsonSerializer = ElectOneSignalConstants.NewtonsoftJsonSerializer; }) .AppendPathSegment($"players/{id}") .WithHeader("Authorization", $"Basic {appInfo.ApiKey}") .PutJsonAsync(model) .ConfigureAwait(true); } catch (FlurlHttpException e) { var response = await e.GetResponseStringAsync().ConfigureAwait(true); throw new HttpRequestException(response); } }
public ActionResult Edit(DeviceEditModel model) { if (this.ModelState.IsValid) { var deviceName = this.devices .GetAll() .FirstOrDefault(x => x.Name.ToLower() == model.Name.ToLower()); if (deviceName == null) { var device = this.Mapper.Map<Device>(model); this.devices.Update(model.Id, device); TempData["Success"] = GlobalConstants.DeviceUpdateNotify; } else { TempData["Warning"] = GlobalConstants.DeviceExistsNotify; } return this.Redirect("/Admin/Devices/Index"); } return this.View(model); }
public async Task EditAsync([NotNull] string id, [NotNull] DeviceEditModel model, [NotNull] string appId) { var appInfo = Options.Apps.Single(x => x.AppId == appId); await EditAsync(id, model, appInfo); }
public IActionResult UpdatesDevice(DeviceEditModel model) { return(Result(() => _deviceService.UpdateDevice(model))); }
public IActionResult Update(DeviceEditModel model) { _deviceManager.ChangeTemperature(model.DeviceId, model.Temperature); return(RedirectToAction("Index")); }