86 lines
3.6 KiB
Plaintext
86 lines
3.6 KiB
Plaintext
@using NetinaShop.Common.Models.Exception
|
|
@using NetinaShop.Domain.CommandQueries.Commands
|
|
@using NetinaShop.Domain.Entities.Brands
|
|
|
|
@inject ISnackbar Snackbar
|
|
@inject IRestWrapper RestWrapper
|
|
@inject IUserUtility UserUtility
|
|
|
|
<MudDialog class="mx-auto">
|
|
<DialogContent>
|
|
<MudStack>
|
|
<MudDivider class="-mt-3" />
|
|
<MudStack Spacing="0">
|
|
|
|
<MudText Typo="Typo.h6">اطلاعات کلی</MudText>
|
|
<MudText Typo="Typo.caption">اطلاعات کلی دسته بندی محصول را به دقت وارد کنید</MudText>
|
|
</MudStack>
|
|
<MudGrid>
|
|
<MudItem lg="6" md="6">
|
|
<MudTextField T="string" Label="نام برند" @bind-Value="@_name" Variant="Variant.Outlined"></MudTextField>
|
|
</MudItem>
|
|
<MudItem lg="6" md="6">
|
|
<MudSelect T="bool" Label="آیا صفحه شخصی دارد ؟" @bind-Value="@_isMain" ToStringFunc="b=>b.ToPersianString()" Variant="Variant.Outlined" AnchorOrigin="Origin.BottomCenter">
|
|
<MudSelectItem T="bool" Value="true"></MudSelectItem>
|
|
<MudSelectItem T="bool" Value="false" />
|
|
</MudSelect>
|
|
</MudItem>
|
|
<MudItem lg="12" md="12">
|
|
<MudTextField T="string" Label="توضیحاتــ" @bind-Value="@_description" Variant="Variant.Outlined"></MudTextField>
|
|
</MudItem>
|
|
|
|
</MudGrid>
|
|
</MudStack>
|
|
</DialogContent>
|
|
<DialogActions>
|
|
@* <MudStack>
|
|
<BaseButtonUi Icon="@Icons.Material.Outlined.Check" Variant="Variant.Filled" Color="Color.Success" Content="تایید" OnClickCallback="SubmitCreateAsync" />
|
|
<MudButton Variant="Variant.Outlined" Size="Size.Large" Color="Color.Error" OnClick="Cancel">بستن</MudButton>
|
|
|
|
</MudStack> *@
|
|
<MudStack Row="true" class="w-full mx-4 mb-2">
|
|
|
|
<BaseButtonUi class="w-64 rounded-md" IsProcessing="@_isProcessing" Icon="@Icons.Material.Outlined.Check" Variant="Variant.Filled" Color="Color.Success" Content="تایید" OnClickCallback="SubmitCreateAsync" />
|
|
<MudSpacer />
|
|
<MudButton Variant="Variant.Outlined" Size="Size.Large" Color="Color.Error" OnClick="Cancel">بستن</MudButton>
|
|
</MudStack>
|
|
</DialogActions>
|
|
</MudDialog>
|
|
@code {
|
|
[CascadingParameter] MudDialogInstance MudDialog { get; set; }
|
|
|
|
void Cancel() => MudDialog.Cancel();
|
|
private bool _isProcessing = false;
|
|
private string _name = string.Empty;
|
|
private string _description = string.Empty;
|
|
private bool _isMain;
|
|
|
|
private async Task SubmitCreateAsync()
|
|
{
|
|
try
|
|
{
|
|
if (_name.IsNullOrEmpty())
|
|
throw new AppException("لطفا نام برند را وارد کنید");
|
|
_isProcessing = true;
|
|
var token = await UserUtility.GetBearerTokenAsync();
|
|
var request = new CreateBrandCommand(_name, _description, _isMain, string.Empty, new List<StorageFileSDto>());
|
|
await RestWrapper.CrudApiRest<Brand, Guid>(Address.BrandController).Create<CreateBrandCommand>(request, token);
|
|
MudDialog.Close(DialogResult.Ok(true));
|
|
}
|
|
catch (ApiException ex)
|
|
{
|
|
var exe = await ex.GetContentAsAsync<ApiResult>();
|
|
if (exe != null)
|
|
Snackbar.Add(exe.Message, Severity.Error);
|
|
Snackbar.Add(ex.Content, Severity.Error);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
Snackbar.Add(e.Message, Severity.Error);
|
|
}
|
|
finally
|
|
{
|
|
_isProcessing = false;
|
|
}
|
|
}
|
|
} |