public async Task <IActionResult> DeleteConfirmed(Guid id)
        {
            CabinetController cabinetController = await GetController(id);

            Cabinet cabinet = await GetCabinet(cabinetController);

            if (cabinet != null)
            {
                _context.Cabinets.Remove(cabinet);
            }

            ControllerProxy proxy = GetControllerProxy(cabinetController);

            // If the controller isn't connected, force un-enroll it
            if (proxy.ValidateController(cabinetController))
            {
                // Notify the controller that it should delete its JWT token and reset
                await proxy.SendCommandToController("clientDelete");
            }

            // Wait a second or two for completion
            await Task.Delay(TimeSpan.FromSeconds(2));

            _context.Controllers.Remove(cabinetController);

            await _context.SaveChangesAsync();

            return(RedirectToAction(nameof(Index)));
        }
        public async Task <IActionResult> Post(Guid id, [FromBody] ScheduledCommand _scheduledCommand)
        {
            CabinetController cabinetController = await GetController(id);

            if (cabinetController == null)
            {
                return(GetCommandError(_scheduledCommand, ErrorStrings.ControllerNotFound));
            }

            // Make sure the controller is online
            ControllerProxy proxy = GetControllerProxy(cabinetController);

            if (!proxy.ValidateController(cabinetController))
            {
                return(GetCommandError(_scheduledCommand, ErrorStrings.ControllerOffline));
            }

            // Send the command to the proxy
            ScheduledCommand command = await proxy.SendCommandToController(_scheduledCommand.Name, _scheduledCommand.Payload);

            return(new JsonResult(command));
        }