Exemple #1
0
        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));
            }
        }
Exemple #2
0
 protected WebApi2PuginController(WebApi2Plugin webApi2Plugin)
 {
     Context       = new ZvsContext();
     WebApi2Plugin = webApi2Plugin;
 }
 public DeviceValueTriggersController(WebApi2Plugin webApi2Plugin) : base(webApi2Plugin) { }
 protected WebApi2PuginController(WebApi2Plugin webApi2Plugin)
 {
     Context = new ZvsContext();
     WebApi2Plugin = 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) { }
Exemple #9
0
 public SceneStoredCommandsController(WebApi2Plugin webApi2Plugin) : base(webApi2Plugin)
 {
 }
 public DeviceCommandsController(WebApi2Plugin webApi2Plugin) : base(webApi2Plugin)
 {
 }
 public DeviceValueHistoriesController(WebApi2Plugin webApi2Plugin) : base(webApi2Plugin) { }
Exemple #12
0
 public ScenesController(WebApi2Plugin webApi2Plugin) : base(webApi2Plugin)
 {
 }
Exemple #13
0
 public BuiltinCommandsController(WebApi2Plugin webApi2Plugin) : base(webApi2Plugin)
 {
 }
 public DevicesController(WebApi2Plugin webApi2Plugin) : base(webApi2Plugin) { }
 public SceneStoredCommandsController(WebApi2Plugin webApi2Plugin) : base(webApi2Plugin) { }
 public LogEntriesController(WebApi2Plugin webApi2Plugin) : base(webApi2Plugin)
 {
 }
 public ScheduledTasksController(WebApi2Plugin webApi2Plugin) : base(webApi2Plugin)
 {
 }
 public ScheduledTasksController(WebApi2Plugin webApi2Plugin) : base(webApi2Plugin) { }
 public GroupsController(WebApi2Plugin webApi2Plugin) : base(webApi2Plugin)
 {
 }
 public DeviceValueTriggersController(WebApi2Plugin webApi2Plugin) : base(webApi2Plugin)
 {
 }
Exemple #21
0
 public DeviceValueHistoriesController(WebApi2Plugin webApi2Plugin) : base(webApi2Plugin)
 {
 }