Class NoticeController
- Namespace
- adas_core.Controllers
- Assembly
- adas-core.dll
[Route("notices")]
public class NoticeController : ControllerBase
- Inheritance
-
NoticeController
- Inherited Members
- Extension Methods
Constructors
NoticeController(INoticeService)
public NoticeController(INoticeService noticeService)
Parameters
noticeServiceINoticeService
Methods
DeleteNotice(string)
Deletes a notice by its identifier after validating the ObjectId format.
[HttpDelete("{id}")]
[AuthorizeRoles(PermissionEnum.RolesType.AuthSome)]
[PermissionAuthorize("Source", "DisplayId")]
public Task<IActionResult> DeleteNotice(string id)
Parameters
idstringThe string representation of the notice's ObjectId to be deleted.
Returns
- Task<IActionResult>
An IActionResult indicating the result of the delete operation.
Exceptions
- BadRequestException
Thrown when the provided
idis not a valid ObjectId format.
GetAllNotices()
Retrieves all notices for the authorized source, requiring the "DisplayId" permission under the "Source" resource and the AuthSome role.
[HttpGet]
[AuthorizeRoles(PermissionEnum.RolesType.AuthSome)]
[PermissionAuthorize("Source", "DisplayId")]
public Task<IActionResult> GetAllNotices()
Returns
- Task<IActionResult>
An IActionResult containing the list of notices returned by the notice service, wrapped in an HTTP 200 OK response.
GetNoticesById(string)
Retrieves a notice identified by the given id and returns it in the response body.
[HttpGet("{id}")]
[AuthorizeRoles(PermissionEnum.RolesType.AuthSome)]
[PermissionAuthorize("Source", "DisplayId")]
public Task<IActionResult> GetNoticesById(string id)
Parameters
idstringThe identifier of the notice to retrieve.
Returns
- Task<IActionResult>
An IActionResult containing the notice data returned by the notice service.
GetNoticesByType(string)
Retrieves notices filtered by the specified type, returning the matching results as an HTTP 200 response.
[HttpGet("{type}/type")]
[AuthorizeRoles(PermissionEnum.RolesType.AuthSome)]
[PermissionAuthorize("Source", "DisplayId")]
public Task<IActionResult> GetNoticesByType(string type)
Parameters
typestringThe notice type used to filter and retrieve the relevant notices.
Returns
- Task<IActionResult>
An IActionResult containing the notices that match the specified type.
InsertNotice(Notice, string)
Creates a new notice associated with the specified display identifier. Validates the header-provided display identifier format before delegating the insert operation to the notice service.
[HttpPost]
[AuthorizeRoles(PermissionEnum.RolesType.AuthSome)]
[PermissionAuthorize("Source", "DisplayId")]
public Task<IActionResult> InsertNotice(Notice notice, string displayId)
Parameters
noticeNoticeThe notice payload to be created, provided in the request body.
displayIdstringThe display identifier supplied via the request header, which must be a valid ObjectId.
Returns
- Task<IActionResult>
An IActionResult containing the result produced by the notice service insert operation.
Exceptions
- BadRequestException
Thrown when the
displayIdheader value is not a valid ObjectId format.
UpdateNotice(string, Notice)
Updates an existing notice identified by the route id, after validating that the id is a valid object identifier format.
[HttpPut("{id}")]
[AuthorizeRoles(PermissionEnum.RolesType.AuthSome)]
[PermissionAuthorize("Source", "DisplayId")]
public Task<IActionResult> UpdateNotice(string id, Notice notice)
Parameters
idstringThe string identifier of the notice to update, provided in the route.
noticeNoticeThe notice payload containing the updated information.
Returns
- Task<IActionResult>
An IActionResult that produces a 200 OK response when the update succeeds.
Exceptions
- BadRequestException
Thrown when
idis not in a valid object identifier format.