chore
This commit is contained in:
@@ -4,5 +4,10 @@ namespace Atomx.Admin.Client.Models
|
||||
{
|
||||
public class CountryModel:Country
|
||||
{
|
||||
/// <summary>
|
||||
/// 语言
|
||||
/// </summary>
|
||||
public string LanguageId { get; set; } = string.Empty;
|
||||
public List<LocalizedProperty> Localized { get; set; } = new List<LocalizedProperty>();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
<h3>AreaEdit</h3>
|
||||
|
||||
@code {
|
||||
|
||||
}
|
||||
207
Atomx.Admin/Atomx.Admin.Client/Pages/Settings/AreaList.razor
Normal file
207
Atomx.Admin/Atomx.Admin.Client/Pages/Settings/AreaList.razor
Normal file
@@ -0,0 +1,207 @@
|
||||
@page "/area/list/{countryId:long}"
|
||||
@page "/{locale}/area/list/{countryId:long}"
|
||||
@inject ILogger<CountryList> Logger
|
||||
@attribute [Authorize]
|
||||
|
||||
|
||||
|
||||
<PageContainer Title="国家管理">
|
||||
<Breadcrumb>
|
||||
<Breadcrumb>
|
||||
<BreadcrumbItem>Home</BreadcrumbItem>
|
||||
<BreadcrumbItem>系统配置</BreadcrumbItem>
|
||||
<BreadcrumbItem>国家管理</BreadcrumbItem>
|
||||
</Breadcrumb>
|
||||
</Breadcrumb>
|
||||
<ChildContent>
|
||||
<Spin Spinning="pageLoading">
|
||||
<Card>
|
||||
<Form @ref="searchForm" Model="search" Layout="FormLayout.Inline" Class="search-form" OnFinish="OnSearchFinish">
|
||||
<Row Justify="RowJustify.Start" Gutter="16">
|
||||
<Col>
|
||||
<FormItem Label="名称">
|
||||
<Input @bind-Value="search.Name" Placeholder="名称" AllowClear />
|
||||
</FormItem>
|
||||
<div class="ant-form-item">
|
||||
<Button Type="ButtonType.Primary" HtmlType="submit">查询</Button>
|
||||
<Button Style="margin: 0 8px;" OnClick="OnSearchReset">重置</Button>
|
||||
</div>
|
||||
</Col>
|
||||
</Row>
|
||||
</Form>
|
||||
</Card>
|
||||
<Card Title="" Class="hideborder">
|
||||
<Extra>
|
||||
<div class="extraContent">
|
||||
<Button Type="ButtonType.Primary" HtmlType="submit" OnClick="HandleAddNew">新增国家</Button>
|
||||
</div>
|
||||
</Extra>
|
||||
<ChildContent>
|
||||
<Table DataSource="PagingList.Items" PageSize="100" HidePagination="true">
|
||||
<Selection CheckStrictly />
|
||||
<PropertyColumn Property="c => c.Name" Title="名称" />
|
||||
<PropertyColumn Property="c => c.Initial" Title="首字母" />
|
||||
<PropertyColumn Property="c => c.NumericISOCode" Title="ISO代码" />
|
||||
<PropertyColumn Property="c => c.Enabled" Title="状态">
|
||||
@if (context.Enabled)
|
||||
{
|
||||
<Text>已激活</text>
|
||||
}
|
||||
else
|
||||
{
|
||||
<Text>未激活</text>
|
||||
}
|
||||
</PropertyColumn>
|
||||
<PropertyColumn Property="c => c.DisplayOrder" Title="排序" />
|
||||
<ActionColumn Title="操作" Align="ColumnAlign.Right">
|
||||
<Space>
|
||||
<SpaceItem>
|
||||
<a @onclick="(e)=>HandleEdit(context)">编辑</a>
|
||||
</SpaceItem>
|
||||
@*<SpaceItem>
|
||||
<Popconfirm Placement="@Placement.Left" Title="@("删除这条数据无法恢复,您确定要删除吗?")"
|
||||
OnConfirm="@(e=>HandleDeleteConfirmAsync(e,context.Id))"
|
||||
OkText="确定"
|
||||
CancelText="取消">
|
||||
<a>删除</a>
|
||||
</Popconfirm>
|
||||
</SpaceItem>*@
|
||||
</Space>
|
||||
</ActionColumn>
|
||||
</Table>
|
||||
<br />
|
||||
<Row Justify="RowJustify.End">
|
||||
@if (PagingList.Count > 0)
|
||||
{
|
||||
<Pagination Current="PagingList.Index" Total="PagingList.Count" PageSize="PagingList.Size" ShowSizeChanger="false" OnChange="OnPageChanged"></Pagination>
|
||||
}
|
||||
</Row>
|
||||
</ChildContent>
|
||||
</Card>
|
||||
</Spin>
|
||||
</ChildContent>
|
||||
</PageContainer>
|
||||
|
||||
@code {
|
||||
[Parameter]
|
||||
public string Locale { get; set; } = string.Empty;
|
||||
[Parameter]
|
||||
public long CountryId { get; set; }
|
||||
|
||||
[SupplyParameterFromQuery]
|
||||
int? Page { get; set; }
|
||||
|
||||
[SupplyParameterFromQuery(Name = "size")]
|
||||
int? PageSize { get; set; }
|
||||
|
||||
bool pageLoading = false;
|
||||
|
||||
Form<CountrySearch> searchForm = new();
|
||||
CountrySearch search = new();
|
||||
|
||||
PagingList<Country> PagingList = new() { Size = 20 };
|
||||
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
await base.OnInitializedAsync();
|
||||
}
|
||||
|
||||
protected override async Task OnParametersSetAsync()
|
||||
{
|
||||
loadQueryString();
|
||||
await LoadListAsync();
|
||||
await base.OnParametersSetAsync();
|
||||
}
|
||||
|
||||
void loadQueryString()
|
||||
{
|
||||
var uri = new Uri(Navigation.Uri);
|
||||
var query = uri.Query;
|
||||
search.Name = query.GetQueryString("Name");
|
||||
}
|
||||
|
||||
async Task LoadListAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
pageLoading = true;
|
||||
var url = "/api/country/search";
|
||||
var apiResult = await HttpService.GetPagingList<Country>(url, search, Page.GetValueOrDefault(1), PageSize.GetValueOrDefault(20));
|
||||
if (apiResult.Success)
|
||||
{
|
||||
if (apiResult.Data != null)
|
||||
{
|
||||
PagingList = apiResult.Data;
|
||||
}
|
||||
}
|
||||
else if (apiResult.Code == 403)
|
||||
{
|
||||
ModalService.Error(new ConfirmOptions() { Title = "权限不足", Content = apiResult.Message });
|
||||
}
|
||||
|
||||
StateHasChanged();
|
||||
}
|
||||
finally
|
||||
{
|
||||
pageLoading = false;
|
||||
}
|
||||
}
|
||||
|
||||
void OnSearchReset()
|
||||
{
|
||||
search = new CountrySearch();
|
||||
searchForm?.Reset();
|
||||
}
|
||||
|
||||
private void OnSearch(int page)
|
||||
{
|
||||
var queryString = search.BuildQueryString();
|
||||
if (string.IsNullOrEmpty(queryString))
|
||||
{
|
||||
if (page > 1)
|
||||
{
|
||||
Navigation.NavigateTo($"/country/list?page={page}");
|
||||
}
|
||||
else
|
||||
{
|
||||
Navigation.NavigateTo($"/country/list");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (page > 1)
|
||||
{
|
||||
Navigation.NavigateTo($"/country/list?page={page}&{queryString}");
|
||||
}
|
||||
else
|
||||
{
|
||||
Navigation.NavigateTo($"/country/list?{queryString}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void OnSearchFinish()
|
||||
{
|
||||
Page = Page.GetValueOrDefault(1) - 1;
|
||||
|
||||
OnSearch(Page.Value);
|
||||
}
|
||||
|
||||
private void OnPageChanged(PaginationEventArgs args)
|
||||
{
|
||||
OnSearch(args.Page);
|
||||
}
|
||||
|
||||
void HandleAddNew()
|
||||
{
|
||||
Navigation.NavigateTo($"/country/create");
|
||||
}
|
||||
|
||||
|
||||
void HandleEdit(Country model)
|
||||
{
|
||||
Navigation.NavigateTo($"/country/edit/{model.Id}");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -17,29 +17,43 @@
|
||||
<ChildContent>
|
||||
|
||||
<Spin Spinning="pageLoading">
|
||||
<Card Title="货币信息">
|
||||
<Card Title="国家信息">
|
||||
<Form @ref="editform" Model="@model" LabelColSpan="5" WrapperColSpan="14" OnFinish="OnFormFinishAsync">
|
||||
@if (Id > 0 && languageList.Any())
|
||||
{
|
||||
<Tabs ActiveKey="@context.LanguageId" OnTabClick="OnLanguageTabChange">
|
||||
<TabPane Key="0">
|
||||
<TabTemplate>
|
||||
<span>标准</span>
|
||||
</TabTemplate>
|
||||
</TabPane>
|
||||
@foreach (var item in languageList)
|
||||
{
|
||||
<TabPane Key="@item.Key.ToString()">
|
||||
<TabTemplate>
|
||||
<span>@item.Value</span>
|
||||
</TabTemplate>
|
||||
</TabPane>
|
||||
}
|
||||
</Tabs>
|
||||
}
|
||||
<FormItem Label="名称" Required>
|
||||
<Input @bind-Value="@context.Name" Placeholder="货币名称" />
|
||||
<Input @bind-Value="@context.Name" Placeholder="国家" />
|
||||
</FormItem>
|
||||
<FormItem Label="货币代码">
|
||||
<Input @bind-Value="@context.CurrencyCode" Placeholder="货币代码" />
|
||||
<FormItem Label="首字母">
|
||||
<Input @bind-Value="@context.Initial" Placeholder="首字母" />
|
||||
</FormItem>
|
||||
<FormItem Label="汇率">
|
||||
<Input @bind-Value="@context.Rate" Placeholder="汇率" />
|
||||
<FormItem Label="两个字母ISO代码">
|
||||
<Input @bind-Value="@context.TwoLetterISOCode" Placeholder="两个字母ISO代码" />
|
||||
</FormItem>
|
||||
<FormItem Label="展示本地">
|
||||
<SimpleSelect @bind-Value="@context.DisplayLocale" Placeholder="语言文化">
|
||||
<SelectOptions>
|
||||
@foreach (var item in LanguageCultures)
|
||||
{
|
||||
<SimpleSelectOption Value="@item.Key" Label="@($"{item.Value} - {item.Key}")"></SimpleSelectOption>
|
||||
}
|
||||
</SelectOptions>
|
||||
</SimpleSelect>
|
||||
<FormItem Label="三字母ISO代码">
|
||||
<Input @bind-Value="@context.ThreeLetterISOCode" Placeholder="三字母ISO代码" />
|
||||
</FormItem>
|
||||
<FormItem Label="自定义格式">
|
||||
<Input @bind-Value="@context.CustomFormatting" Placeholder="自定义格式" />
|
||||
<FormItem Label="数字ISO代码">
|
||||
<Input @bind-Value="@context.NumericISOCode" Placeholder="数字ISO代码" />
|
||||
</FormItem>
|
||||
<FormItem Label="允许发货">
|
||||
<Checkbox Checked="@context.AllowShipping">允许发货</Checkbox>
|
||||
</FormItem>
|
||||
<FormItem Label="显示排序">
|
||||
<Input @bind-Value="@context.DisplayOrder" Placeholder="显示排序" />
|
||||
@@ -65,9 +79,13 @@
|
||||
public long Id { get; set; }
|
||||
|
||||
[SupplyParameterFromForm]
|
||||
CurrencyModel model { get; set; } = new();
|
||||
Form<CurrencyModel> editform = null!;
|
||||
Dictionary<string, string> LanguageCultures = LanguageCulture.Descriptions.ToDictionary();
|
||||
CountryModel model { get; set; } = new();
|
||||
Form<CountryModel> editform = null!;
|
||||
|
||||
Country Country = new();
|
||||
|
||||
List<KeyValue> languageList = new();
|
||||
|
||||
bool pageLoading = false;
|
||||
bool saving = false;
|
||||
|
||||
@@ -85,6 +103,16 @@
|
||||
base.OnParametersSet();
|
||||
}
|
||||
|
||||
async Task LoadLanguage()
|
||||
{
|
||||
var url = $"/api/language/enabled";
|
||||
var apiResult = await HttpService.Get<ApiResult<List<KeyValue>>>(url);
|
||||
if (apiResult.Success)
|
||||
{
|
||||
languageList = apiResult.Data ?? new List<KeyValue>();
|
||||
}
|
||||
}
|
||||
|
||||
async void LoadData()
|
||||
{
|
||||
pageLoading = true;
|
||||
@@ -98,7 +126,7 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
model = apiResult.Data.Adapt<CurrencyModel>();
|
||||
model = apiResult.Data.Adapt<CountryModel>();
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -134,4 +162,30 @@
|
||||
}
|
||||
}
|
||||
|
||||
void OnLanguageTabChange(string key)
|
||||
{
|
||||
if (key != "0")
|
||||
{
|
||||
model.LanguageId = key;
|
||||
var data = model.Localized.Where(p => p.LanguageId == key.ToInt()).ToList();
|
||||
if (data.Any())
|
||||
{
|
||||
var name = nameof(model.Name);
|
||||
|
||||
model.Name = data.SingleOrDefault(p => p.Key == name)?.Value ?? "";
|
||||
}
|
||||
else
|
||||
{
|
||||
model.Name = string.Empty;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// model = Mapper.Map<CountryModel>(model);
|
||||
|
||||
// model.LanguageId = key;
|
||||
// model.IsEdit = true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -5,12 +5,12 @@
|
||||
|
||||
|
||||
|
||||
<PageContainer Title="国家地区">
|
||||
<PageContainer Title="国家管理">
|
||||
<Breadcrumb>
|
||||
<Breadcrumb>
|
||||
<BreadcrumbItem>Home</BreadcrumbItem>
|
||||
<BreadcrumbItem>系统配置</BreadcrumbItem>
|
||||
<BreadcrumbItem>货币管理</BreadcrumbItem>
|
||||
<BreadcrumbItem>国家管理</BreadcrumbItem>
|
||||
</Breadcrumb>
|
||||
</Breadcrumb>
|
||||
<ChildContent>
|
||||
@@ -22,41 +22,9 @@
|
||||
<FormItem Label="名称">
|
||||
<Input @bind-Value="search.Name" Placeholder="名称" AllowClear />
|
||||
</FormItem>
|
||||
</Col>
|
||||
@if (searchExpand)
|
||||
{
|
||||
<AntDesign.Col>
|
||||
<FormItem Label="发布时间">
|
||||
<RangePicker @bind-Value="search.RangeTime"></RangePicker>
|
||||
</FormItem>
|
||||
</AntDesign.Col>
|
||||
<AntDesign.Col>
|
||||
<FormItem Label="状态">
|
||||
<SimpleSelect DefaultValue="" Style="width:120px;" @bind-Value="@search.Status">
|
||||
<SelectOptions>
|
||||
<SimpleSelectOption Value="" Label="全部"></SimpleSelectOption>
|
||||
<SimpleSelectOption Value="1" Label="草稿"></SimpleSelectOption>
|
||||
<SimpleSelectOption Value="2" Label="已发布"></SimpleSelectOption>
|
||||
<SimpleSelectOption Value="3" Label="已删除"></SimpleSelectOption>
|
||||
</SelectOptions>
|
||||
</SimpleSelect>
|
||||
</FormItem>
|
||||
</AntDesign.Col>
|
||||
}
|
||||
<Col>
|
||||
<div class="ant-form-item">
|
||||
<Button Type="ButtonType.Primary" HtmlType="submit">查询</Button>
|
||||
<Button Style="margin: 0 8px;" OnClick="OnSearchReset">重置</Button>
|
||||
<a style="font-size:12px; display:flex; align-items:center;text-align:center;" @onclick="()=>{searchExpand=!searchExpand;}">
|
||||
<Icon Type="@(searchExpand?"up":"down")"></Icon> @if (searchExpand)
|
||||
{
|
||||
<span>收起</span>
|
||||
}
|
||||
else
|
||||
{
|
||||
<span>展开</span>
|
||||
}
|
||||
</a>
|
||||
</div>
|
||||
</Col>
|
||||
</Row>
|
||||
@@ -65,25 +33,15 @@
|
||||
<Card Title="" Class="hideborder">
|
||||
<Extra>
|
||||
<div class="extraContent">
|
||||
<Button Type="ButtonType.Primary" HtmlType="submit" OnClick="HandleAddNew">新增货币</Button>
|
||||
<Button Type="ButtonType.Primary" HtmlType="submit" OnClick="HandleAddNew">新增国家</Button>
|
||||
</div>
|
||||
</Extra>
|
||||
<ChildContent>
|
||||
<Table DataSource="PagingList.Items" PageSize="100" HidePagination="true">
|
||||
<Selection CheckStrictly />
|
||||
<PropertyColumn Property="c => c.Name" Title="名称" />
|
||||
<PropertyColumn Property="c => c.CurrencyCode" Title="货币代码" />
|
||||
<PropertyColumn Property="c => c.Rate" Title="汇率" />
|
||||
<PropertyColumn Property="c => c.PrimaryCurrency" Title="默认货币">
|
||||
@if (context.PrimaryCurrency)
|
||||
{
|
||||
<AntDesign.Text Type="TextElementType.Success"><Icon Type="check" Theme="IconThemeType.Outline" /></AntDesign.Text>
|
||||
}
|
||||
else
|
||||
{
|
||||
<Icon Type="minus" Theme="IconThemeType.Outline" />
|
||||
}
|
||||
</PropertyColumn>
|
||||
<PropertyColumn Property="c => c.Initial" Title="首字母" />
|
||||
<PropertyColumn Property="c => c.NumericISOCode" Title="ISO代码" />
|
||||
<PropertyColumn Property="c => c.Enabled" Title="状态">
|
||||
@if (context.Enabled)
|
||||
{
|
||||
@@ -135,12 +93,11 @@
|
||||
int? PageSize { get; set; }
|
||||
|
||||
bool pageLoading = false;
|
||||
bool searchExpand = false;
|
||||
|
||||
Form<CurrencySearchModel> searchForm = new();
|
||||
CurrencySearchModel search = new();
|
||||
Form<CountrySearch> searchForm = new();
|
||||
CountrySearch search = new();
|
||||
|
||||
PagingList<CurrencyModel> PagingList = new() { Size = 20 };
|
||||
PagingList<Country> PagingList = new() { Size = 20 };
|
||||
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
@@ -160,21 +117,6 @@
|
||||
var uri = new Uri(Navigation.Uri);
|
||||
var query = uri.Query;
|
||||
search.Name = query.GetQueryString("Name");
|
||||
search.Status = query.GetQueryString("Status");
|
||||
|
||||
var data = query.GetQueryString("RangeTime");
|
||||
if (!string.IsNullOrEmpty(data))
|
||||
{
|
||||
var rangetime = data.Split("-");
|
||||
if (rangetime != null && rangetime.Length > 0)
|
||||
{
|
||||
searchExpand = true;
|
||||
search.RangeTime[0] = rangetime[0].NumberToDateTime();
|
||||
search.RangeTime[1] = rangetime[1].NumberToDateTime();
|
||||
StateHasChanged();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
async Task LoadListAsync()
|
||||
@@ -182,8 +124,8 @@
|
||||
try
|
||||
{
|
||||
pageLoading = true;
|
||||
var url = "/api/currency/search";
|
||||
var apiResult = await HttpService.GetPagingList<CurrencyModel>(url, search, Page.GetValueOrDefault(1), PageSize.GetValueOrDefault(20));
|
||||
var url = "/api/country/search";
|
||||
var apiResult = await HttpService.GetPagingList<Country>(url, search, Page.GetValueOrDefault(1), PageSize.GetValueOrDefault(20));
|
||||
if (apiResult.Success)
|
||||
{
|
||||
if (apiResult.Data != null)
|
||||
@@ -206,7 +148,7 @@
|
||||
|
||||
void OnSearchReset()
|
||||
{
|
||||
search = new CurrencySearchModel();
|
||||
search = new CountrySearch();
|
||||
searchForm?.Reset();
|
||||
}
|
||||
|
||||
@@ -217,22 +159,22 @@
|
||||
{
|
||||
if (page > 1)
|
||||
{
|
||||
Navigation.NavigateTo($"/currency/list?page={page}");
|
||||
Navigation.NavigateTo($"/country/list?page={page}");
|
||||
}
|
||||
else
|
||||
{
|
||||
Navigation.NavigateTo($"/currency/list");
|
||||
Navigation.NavigateTo($"/country/list");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (page > 1)
|
||||
{
|
||||
Navigation.NavigateTo($"/currency/list?page={page}&{queryString}");
|
||||
Navigation.NavigateTo($"/country/list?page={page}&{queryString}");
|
||||
}
|
||||
else
|
||||
{
|
||||
Navigation.NavigateTo($"/currency/list?{queryString}");
|
||||
Navigation.NavigateTo($"/country/list?{queryString}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -251,17 +193,13 @@
|
||||
|
||||
void HandleAddNew()
|
||||
{
|
||||
Navigation.NavigateTo($"/currency/create");
|
||||
Navigation.NavigateTo($"/country/create");
|
||||
}
|
||||
|
||||
|
||||
void HandleEdit(CurrencyModel model)
|
||||
void HandleEdit(Country model)
|
||||
{
|
||||
Navigation.NavigateTo($"/currency/edit/{model.Id}");
|
||||
Navigation.NavigateTo($"/country/edit/{model.Id}");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@code {
|
||||
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ namespace Atomx.Admin.Controllers
|
||||
/// <returns></returns>
|
||||
[HttpPost("searh")]
|
||||
[Authorize(Policy = Permissions.User.View)]
|
||||
public IActionResult AddressList(CountrySearch search, int page, int size = 20)
|
||||
public IActionResult Search(CountrySearch search, int page, int size = 20)
|
||||
{
|
||||
if (page < 1)
|
||||
{
|
||||
@@ -87,6 +87,29 @@ namespace Atomx.Admin.Controllers
|
||||
return new JsonResult(result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 详情,含多语言
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("detail")]
|
||||
public IActionResult Detail(long id)
|
||||
{
|
||||
var result = new ApiResult<CountryLocalizedModel>();
|
||||
var data = _dbContext.Countries.SingleOrDefault(p => p.Id == id);
|
||||
if(data == null)
|
||||
{
|
||||
return new JsonResult(new ApiResult<string>().IsFail("数据不存在", null));
|
||||
}
|
||||
var localizedList = _dbContext.LocalizedProperties.Where(p => p.EntityId == id).ToList();
|
||||
var model = _mapper.Map<CountryLocalizedModel>(data);
|
||||
model.Locales = localizedList;
|
||||
|
||||
result = result.IsSuccess(model);
|
||||
|
||||
return new JsonResult(result);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 新增编辑数据
|
||||
@@ -94,7 +117,7 @@ namespace Atomx.Admin.Controllers
|
||||
/// <param name="model"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("save")]
|
||||
public IActionResult AddressEdit(CountryModel model)
|
||||
public IActionResult Save(CountryModel model)
|
||||
{
|
||||
var result = new ApiResult<bool>();
|
||||
var validation = _validator.Validate(model);
|
||||
@@ -140,7 +163,7 @@ namespace Atomx.Admin.Controllers
|
||||
/// <returns></returns>
|
||||
|
||||
[HttpPost("delete")]
|
||||
public async Task<IActionResult> DeleteAsync(long id)
|
||||
public async Task<IActionResult> Delete(long id)
|
||||
{
|
||||
var result = new ApiResult<string>();
|
||||
try
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using Atomx.Admin.Client.Models;
|
||||
using Atomx.Admin.Client.Validators;
|
||||
using Atomx.Admin.Services;
|
||||
using Atomx.Common.Entities;
|
||||
using Atomx.Common.Models;
|
||||
@@ -12,6 +11,7 @@ using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Atomx.Admin.Controllers
|
||||
{
|
||||
@@ -61,9 +61,11 @@ namespace Atomx.Admin.Controllers
|
||||
[HttpGet("enabled")]
|
||||
public async Task<IActionResult> CacheLanguage()
|
||||
{
|
||||
var result = new ApiResult<List<Language>>();
|
||||
var result = new ApiResult<List<KeyValue>>();
|
||||
|
||||
var list = await _cacheService.GetLanguages(true);
|
||||
var data = await _cacheService.GetLanguages();
|
||||
|
||||
var list = data.Where(p => p.Enabled).Select(p => new KeyValue() { Key = p.Id.ToString(), Value = p.Name }).ToList();
|
||||
|
||||
result = result.IsSuccess(list);
|
||||
|
||||
@@ -184,13 +186,14 @@ namespace Atomx.Admin.Controllers
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("delete/{id:long}")]
|
||||
public IActionResult Delete(long id)
|
||||
public async Task<IActionResult> Delete(long id)
|
||||
{
|
||||
var result = new ApiResult<string>();
|
||||
try
|
||||
{
|
||||
Console.WriteLine($"{id} deleted");
|
||||
var count = _dbContext.Languages.Where(p => p.Id == id).ExecuteDelete();
|
||||
await _cacheService.GetLanguages(true);
|
||||
result = result.IsSuccess(count.ToString());
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
||||
@@ -34,13 +34,15 @@ namespace Atomx.Admin.Controllers
|
||||
/// <param name="adminService"></param>
|
||||
/// <param name="mapper"></param>
|
||||
public UploadFileController(ILogger<UploadFileController> logger, IIdentityService identityService, IIdCreatorService idCreator, IMapper mapper, DataContext dataContext,
|
||||
IValidator<StateProvinceModel> validator, IStringLocalizer<StateProvinceController> localizer)
|
||||
IValidator<UploadFileModel> validator, IStringLocalizer<UploadFileController> localizer)
|
||||
{
|
||||
_logger = logger;
|
||||
_identityService = identityService;
|
||||
_idCreator = idCreator;
|
||||
_mapper = mapper;
|
||||
_dbContext = dataContext;
|
||||
_validator = validator;
|
||||
_localizer = localizer;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user