Class DeviceController
- Namespace
- adas_core.Controllers
- Assembly
- adas-core.dll
[Route("device")]
[ApiController]
public class DeviceController : ControllerBase
- Inheritance
-
DeviceController
- Inherited Members
- Extension Methods
Constructors
DeviceController(IDeviceService)
public DeviceController(IDeviceService deviceService)
Parameters
deviceServiceIDeviceService
Methods
CreateDevice(string)
Deletes a device by its identifier. Validates the ID format, returning BadRequest for invalid IDs, and returns Conflict if the deletion cannot be completed.
[HttpDelete("delete/{id}")]
[AuthorizeRoles(PermissionEnum.RolesType.AuthSome)]
public Task<IActionResult> CreateDevice(string id)
Parameters
idstringThe string representation of the device's ObjectId to delete.
Returns
- Task<IActionResult>
An IActionResult indicating the outcome of the delete operation.
CreateDevice(DeviceDto)
Creates a new device based on the provided device data. Returns a conflict response when the creation result is null, indicating the device could not be created.
[HttpPost("add")]
[AuthorizeRoles(PermissionEnum.RolesType.AuthSome)]
public Task<IActionResult> CreateDevice(DeviceDto device)
Parameters
deviceDeviceDtoThe device data transfer object containing the information of the device to be created.
Returns
- Task<IActionResult>
An IActionResult containing the created device on success, or a Conflict response if the creation fails.
EditDevice(DeviceDto)
Updates an existing device with the provided data. Returns a conflict response if the update operation produces no result, otherwise returns the updated device.
[HttpPut("edit")]
[AuthorizeRoles(PermissionEnum.RolesType.AuthSome)]
public Task<IActionResult> EditDevice(DeviceDto device)
Parameters
deviceDeviceDtoThe device data transfer object containing the updated device information.
Returns
- Task<IActionResult>
An IActionResult containing the updated device on success, or a ConflictResult when the update returns null.
ReceiveEventDevice(DeviceDto)
Handles an incoming device event submitted by an authorized client. Delegates processing to the device service and returns a conflict response when the device cannot be created.
[HttpPost("event")]
[AuthorizeRoles(PermissionEnum.RolesType.AuthSome)]
public Task<IActionResult> ReceiveEventDevice(DeviceDto device)
Parameters
deviceDeviceDtoThe device payload received in the request body to be processed as an event.
Returns
- Task<IActionResult>
An IActionResult that returns OkResult on successful processing, or ConflictResult with a message when the service cannot create the device.