public async Task <IHttpActionResult> Execute([FromODataUri] int key, ODataActionParameters parameters) { if (!ModelState.IsValid) { return(BadRequest()); } var arg1 = (string)parameters["Argument"]; var arg2 = (string)parameters["Argument2"]; try { using (var context = new ZvsContext(WebApi2Plugin.EntityContextConnection)) { var command = await context.Commands.FirstOrDefaultAsync(o => o.Id == key); if (command == null) { return(NotFound()); } var result = await WebApi2Plugin.RunCommandAsync(command.Id, arg1, arg2, CancellationToken.None); if (result.HasError) { return(BadRequest(result.Message)); } return(Ok(result.Message)); } } catch (Exception e) { return(BadRequest(e.Message)); } }
protected WebApi2PuginController(WebApi2Plugin webApi2Plugin) { Context = new ZvsContext(); WebApi2Plugin = webApi2Plugin; }
public DeviceValueTriggersController(WebApi2Plugin webApi2Plugin) : base(webApi2Plugin) { }
public GroupsController(WebApi2Plugin webApi2Plugin) : base(webApi2Plugin) { }
public DeviceTypeCommandsController(WebApi2Plugin webApi2Plugin) : base(webApi2Plugin) { }
public LogEntriesController(WebApi2Plugin webApi2Plugin) : base(webApi2Plugin) { }
public CommandsController(WebApi2Plugin webApi2Plugin) : base(webApi2Plugin) { }
public SceneStoredCommandsController(WebApi2Plugin webApi2Plugin) : base(webApi2Plugin) { }
public DeviceCommandsController(WebApi2Plugin webApi2Plugin) : base(webApi2Plugin) { }
public DeviceValueHistoriesController(WebApi2Plugin webApi2Plugin) : base(webApi2Plugin) { }
public ScenesController(WebApi2Plugin webApi2Plugin) : base(webApi2Plugin) { }
public BuiltinCommandsController(WebApi2Plugin webApi2Plugin) : base(webApi2Plugin) { }
public DevicesController(WebApi2Plugin webApi2Plugin) : base(webApi2Plugin) { }
public ScheduledTasksController(WebApi2Plugin webApi2Plugin) : base(webApi2Plugin) { }