Use REST style

This commit is contained in:
hishamco
2020-12-03 15:50:25 +03:00
parent 5ee38e4ae7
commit 1a8125c26d
5 changed files with 12 additions and 25 deletions

View File

@ -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
};
}
}
}