Saving
This commit is contained in:
1 parent
9719a0c0fd
commit
1e66851113
146 files changed
+738
-382
No files matched your search
@@ -0,0 +1,55 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
using PrivaPub.ClientModels;
|
||||
using PrivaPub.ClientModels.Data;
|
||||
using PrivaPub.Services.ClientToServer.Public;
|
||||
|
||||
namespace PrivaPub.Controllers.ClientToServer
|
||||
{
|
||||
[ApiController,
|
||||
Route("clientapi/data")]
|
||||
public class DataController : ControllerBase
|
||||
{
|
||||
readonly IDataService DataService;
|
||||
readonly ILogger<DataController> Logger;
|
||||
|
||||
public DataController(IDataService dataService,
|
||||
ILogger<DataController> logger)
|
||||
{
|
||||
DataService = dataService;
|
||||
Logger = logger;
|
||||
}
|
||||
|
||||
[HttpGet, Route("/clientapi/data/ping"), AllowAnonymous]
|
||||
public async ValueTask<IActionResult> Ping() => NoContent();
|
||||
|
||||
[HttpGet, Route("/clientapi/data/current-version"), AllowAnonymous]
|
||||
public IActionResult CurrentVersion() =>
|
||||
Ok(DataService.GetCurrentVersion());
|
||||
|
||||
[HttpGet, Route("/clientapi/data/languages"), AllowAnonymous]
|
||||
public async Task<IActionResult> Languages(CancellationToken cancellationToken)
|
||||
{
|
||||
var result = new WebResult();
|
||||
try
|
||||
{
|
||||
var languages = await DataService.GetLanguages(cancellationToken);
|
||||
var viewLanguages = new List<ViewLanguage>();
|
||||
|
||||
viewLanguages.AddRange(languages.Select(l => new ViewLanguage
|
||||
{
|
||||
Name = l.NativeName,
|
||||
International2Code = l.International2Code
|
||||
}).ToArray());
|
||||
|
||||
return Ok(viewLanguages);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.LogError(ex, $"{nameof(DataController)}.{nameof(Languages)}()");
|
||||
return BadRequest(result.Invalidate(ex.Message, exception: ex));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user