예제 #1
0
        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);
        }
예제 #2
0
        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());
        }
예제 #3
0
 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());
     }
 }
예제 #4
0
 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));
 }
예제 #5
0
        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);
            }
        }
예제 #6
0
        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);
        }
예제 #7
0
        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);
        }
예제 #8
0
 public IActionResult UpdatesDevice(DeviceEditModel model)
 {
     return(Result(() => _deviceService.UpdateDevice(model)));
 }
예제 #9
0
 public IActionResult Update(DeviceEditModel model)
 {
     _deviceManager.ChangeTemperature(model.DeviceId, model.Temperature);
     return(RedirectToAction("Index"));
 }