Class TrinityMainController
- Namespace
- AbanoubNassem.Trinity.Controllers
- Assembly
- AbanoubNassem.Trinity.dll
Controller for the main pages of the application.
public sealed class TrinityMainController : TrinityController, IActionFilter, IAsyncActionFilter, IFilterMetadata, IDisposable
- Inheritance
-
TrinityMainController
- Implements
- Inherited Members
Remarks
Handles the rendering of the dashboard and login pages, as well as handling user authentication and authorization.
Constructors
TrinityMainController(TrinityConfigurations, TrinityManager, TrinityLocalizer)
Initializes a new instance of the TrinityMainController class.
public TrinityMainController(TrinityConfigurations configurations, TrinityManager trinityManager, TrinityLocalizer localizer)
Parameters
configurations
TrinityConfigurationsThe TrinityConfigurations object to use.
trinityManager
TrinityManagerThe TrinityManager object to use.
localizer
TrinityLocalizerThe TrinityLocalizer object to use.
Methods
DeleteFile(DeleteFileRequest)
Deletes a file from a resource.
[HttpPost]
[Route("/delete/file")]
public Task<IActionResult> DeleteFile(DeleteFileRequest request)
Parameters
request
DeleteFileRequestThe request containing information about the file to delete.
Returns
HandleAction(string, string)
Handles an action on a resource.
[HttpPost]
[Route("/actions/{resourceName}/{actionName}")]
public Task<IActionResult> HandleAction(string resourceName, string actionName)
Parameters
resourceName
stringThe name of the resource on which to handle the action.
actionName
stringThe name of the action to handle.
Returns
HandleResource(string, string)
Handles the request for a resource based on HTTP method and view.
[HttpGet]
[HttpPost]
[HttpPut]
[HttpDelete]
[Route("/{name}/{view=index}/{id?}")]
public Task<IActionResult> HandleResource(string name, string view)
Parameters
name
stringThe name of the resource to handle.
view
stringThe view to handle (defaults to 'index').
Returns
Index()
Renders the dashboard page.
[HttpGet]
public Task<IActionResult> Index()
Returns
- Task<IActionResult>
The rendered page as an IActionResult.
Login()
Renders the login page.
[AllowAnonymous]
[HttpGet]
[Route("/login")]
public IActionResult Login()
Returns
- IActionResult
The rendered page as an IActionResult.
Login(LoginRequest, string?)
Handles user login requests.
[AllowAnonymous]
[HttpPost]
[Route("/login")]
public Task<IActionResult> Login(LoginRequest loginRequest, string? returnUrl = null)
Parameters
loginRequest
LoginRequestThe LoginRequest object containing the user's login information.
returnUrl
stringThe URL to return the user to after logging in.
Returns
- Task<IActionResult>
The rendered page as an IActionResult.
Logout()
Logs out the current user.
[HttpPost]
[Route("/logout")]
public Task<IActionResult> Logout()
Returns
RenderPage(string)
Renders a page based on the provided slug.
[HttpGet]
[Route("/pages/{slug}/")]
public Task<IActionResult> RenderPage(string slug)
Parameters
slug
stringThe slug of the page to render.
Returns
UploadFile(IFormFile?, string, string)
Handles file uploads for a resource.
[HttpPost]
[Route("/upload/file")]
public Task<IActionResult> UploadFile(IFormFile? file, string resourceName, string fieldName)
Parameters
file
IFormFileThe file to upload.
resourceName
stringThe name of the resource for which to upload a file.
fieldName
stringThe name of the field on the resource for which to upload a file.