mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 10:11:10 +00:00
Adds localization to Lumina.Presentation.Web project
This commit is contained in:
1 parent
771fa74991
commit
2c31fd8714
65 files changed
+1111
-319
No files matched your search
+16
-7
@@ -1,12 +1,9 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Presentation.Web.Common.Api;
|
||||
using Lumina.Presentation.Web.Common.Enums.Library;
|
||||
using Lumina.Presentation.Web.Common.Models.Libraries;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.Formatters;
|
||||
using System;
|
||||
using System.Security.Claims;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
#endregion
|
||||
@@ -14,28 +11,40 @@ using System.Threading.Tasks;
|
||||
namespace Lumina.Presentation.Web.Controllers.Library.Management;
|
||||
|
||||
[Authorize]
|
||||
[Route("/library/manage/")]
|
||||
[Route("{culture}/library/manage")]
|
||||
public class LibraryManagementController : Controller
|
||||
{
|
||||
private readonly IApiHttpClient _apiHttpClient;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="LibraryManagementController"/> class.
|
||||
/// </summary>
|
||||
/// <param name="apiHttpClient">Injected service for interactions with the API.</param>
|
||||
public LibraryManagementController(IApiHttpClient apiHttpClient)
|
||||
{
|
||||
_apiHttpClient = apiHttpClient;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Displays the view for displaying the list of media libraries.
|
||||
/// </summary>
|
||||
[HttpGet("")]
|
||||
public IActionResult Index()
|
||||
{
|
||||
return View("/Views/Library/Management/Index.cshtml");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Displays the view for adding or editing a media library.
|
||||
/// </summary>
|
||||
/// <param name="id">The optional id of the media library to edit.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
[HttpGet("item/{id?}")]
|
||||
public async Task<IActionResult> EditLibrary(Guid? id = null, CancellationToken cancellationToken = default)
|
||||
{
|
||||
LibraryModel libraryModel = new();
|
||||
if (id is not null)
|
||||
libraryModel = await _apiHttpClient.GetAsync<LibraryModel>($"libraries/{id}", cancellationToken);
|
||||
libraryModel = await _apiHttpClient.GetAsync<LibraryModel>($"libraries/{id}", cancellationToken).ConfigureAwait(false);
|
||||
return View("/Views/Library/Management/Item.cshtml", libraryModel);
|
||||
}
|
||||
|
||||
@@ -50,8 +59,8 @@ public class LibraryManagementController : Controller
|
||||
{
|
||||
// call different API endpoints based on whether this is a new library or an existing one
|
||||
LibraryModel response = data.Id.HasValue
|
||||
? await _apiHttpClient.PutAsync<LibraryModel, LibraryModel>($"libraries/{data.Id}", data, cancellationToken)
|
||||
: await _apiHttpClient.PostAsync<LibraryModel, LibraryModel>("libraries", data, cancellationToken);
|
||||
? await _apiHttpClient.PutAsync<LibraryModel, LibraryModel>($"libraries/{data.Id}", data, cancellationToken).ConfigureAwait(false)
|
||||
: await _apiHttpClient.PostAsync<LibraryModel, LibraryModel>("libraries", data, cancellationToken).ConfigureAwait(false);
|
||||
return Json(new { success = true, data = response });
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user