Use REST style
This commit is contained in:
parent
5ee38e4ae7
commit
1a8125c26d
|
@ -6,8 +6,6 @@ namespace Oqtane.Services
|
|||
{
|
||||
public interface ILocalizationService
|
||||
{
|
||||
Task<Culture> GetDefaultCulture();
|
||||
|
||||
Task<IEnumerable<Culture>> GetSupportedCultures();
|
||||
Task<IEnumerable<Culture>> GetCulturesAsync();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,9 +17,6 @@ namespace Oqtane.Services
|
|||
|
||||
private string Apiurl => CreateApiUrl(_siteState.Alias, "Localization");
|
||||
|
||||
public async Task<Culture> GetDefaultCulture() => await GetJsonAsync<Culture>($"{Apiurl}/getDefaultCulture");
|
||||
|
||||
public async Task<IEnumerable<Culture>> GetSupportedCultures()
|
||||
=> await GetJsonAsync<IEnumerable<Culture>>($"{Apiurl}/getSupportedCultures");
|
||||
public async Task<IEnumerable<Culture>> GetCulturesAsync() => await GetJsonAsync<IEnumerable<Culture>>(Apiurl);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
{
|
||||
var interop = new Interop(JSRuntime);
|
||||
_selectedCulture = await interop.GetLocalStorage("OqtaneCulture");
|
||||
_supportedCultures = await LocalizationService.GetSupportedCultures();
|
||||
_supportedCultures = await LocalizationService.GetCulturesAsync();
|
||||
}
|
||||
|
||||
private async Task SetCultureAsync(string culture)
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
|
@ -18,25 +19,14 @@ namespace Oqtane.Controllers
|
|||
_localizationManager = localizationManager;
|
||||
}
|
||||
|
||||
// GET: api/localization/getSupportedCultures
|
||||
[HttpGet("getSupportedCultures")]
|
||||
public IEnumerable<Culture> GetSupportedCultures()
|
||||
// GET: api/localization
|
||||
[HttpGet()]
|
||||
public IEnumerable<Culture> Get()
|
||||
=> _localizationManager.GetSupportedCultures().Select(c => new Culture {
|
||||
Name = CultureInfo.GetCultureInfo(c).Name,
|
||||
DisplayName = CultureInfo.GetCultureInfo(c).DisplayName
|
||||
DisplayName = CultureInfo.GetCultureInfo(c).DisplayName,
|
||||
IsDefault = _localizationManager.GetDefaultCulture()
|
||||
.Equals(CultureInfo.GetCultureInfo(c).Name, StringComparison.OrdinalIgnoreCase)
|
||||
});
|
||||
|
||||
// GET api/localization/getDefaultCulture
|
||||
[HttpGet("getDefaultCulture")]
|
||||
public Culture GetDefaultCulture()
|
||||
{
|
||||
var culture = _localizationManager.GetDefaultCulture();
|
||||
|
||||
return new Culture
|
||||
{
|
||||
Name = CultureInfo.GetCultureInfo(culture).Name,
|
||||
DisplayName = CultureInfo.GetCultureInfo(culture).DisplayName
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,5 +5,7 @@ namespace Oqtane.Models
|
|||
public string Name { get; set; }
|
||||
|
||||
public string DisplayName { get; set; }
|
||||
|
||||
public bool IsDefault { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user