-
Notifications
You must be signed in to change notification settings - Fork 0
/
FrontEndDemoContentItemAsyncEditorController.cs
41 lines (34 loc) · 1.58 KB
/
FrontEndDemoContentItemAsyncEditorController.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
using Lombiq.ContentEditors.Samples.Constants;
using Lombiq.ContentEditors.Samples.Services;
using Lombiq.ContentEditors.ViewModels;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using OrchardCore.Modules;
using System.Threading.Tasks;
using static OrchardCore.Contents.CommonPermissions;
namespace Lombiq.ContentEditors.Samples.Controllers;
// In case you want to create an async editor UI on a page other than the admin UI, you can create a similar controller
// to this one.
[Feature(FeatureIds.Samples)]
[Route(Routes.FrontEndContentItemAsyncEditor)]
public sealed class FrontEndDemoContentItemAsyncEditorController : Controller
{
private readonly IAuthorizationService _authorizationService;
public FrontEndDemoContentItemAsyncEditorController(IAuthorizationService authorizationService) =>
_authorizationService = authorizationService;
[HttpGet("{contentItemId?}")]
public async Task<IActionResult> Index(string contentItemId)
{
if (!ModelState.IsValid) return BadRequest(ModelState);
if (!await _authorizationService.AuthorizeAsync(User, EditContent)) return this.ChallengeOrForbid();
// You can use the existing ContentItemAsyncEditorViewModel to pass the required data.
return View(
new ContentItemAsyncEditorViewModel
{
ProviderName = nameof(SupportTicketAsyncEditorProvider),
ContentType = ContentTypes.SupportTicket,
ContentItemId = contentItemId,
});
}
}
// NEXT STATION: Views/FrontEndDemoContentItemAsyncEditor/Index.cshtml