Can some one please help me with a route I am trying to setup
I have to know if I can and how to go about configuring a route list so
localhost/api/device/1/commands/turnOn
{hostname}/{api section}{I will multiple types of devices with diiferent commands}
So some examples:
- localhost/api/device/1/commands/turnOff
- localhost/api/device/1/commands/turnON
- localhost/api/device/1/info/ (will return all info on the device)
- localhost/api/device/1/info/name (will return the name of the device)
- localhost/api/device/1/commands/display/1 (will display a 1 on the device)
The above are just random examples of things I want to do.
But the underlying structure is correct. I want to have multiple devices with device specific commands and options
I don't know how to portray this in a controller? I would think something along the long of a controller for each device The under that device I would have the different sections like command, info ,etc then under each one of those I woudl have the action methods.
But I dont know how to do that.
Any help would be greatly apperecited:
Also what is better practice:
[HttpGet]
public HttpStatusCode Arm()
{
return HttpStatusCode.OK;
}
[HttpGet]
public HttpStatusCode StayArm()
{
return HttpStatusCode.OK;
}
[HttpGet]
public HttpStatusCode Disarm()
{
return HttpStatusCode.OK;
}
or:
[HttpGet]
public HttpStatusCode Command(string command)
{
switch (command)
{
case "arm":
{
}
break;
case "disarm":
{
}
break;
}
return HttpStatusCode.OK;
}