@using NetinaShop.Common.Models.Exception @using NetinaShop.Domain.CommandQueries.Commands @using NetinaShop.Domain.Entities.Brands @inject ISnackbar Snackbar @inject IRestWrapper RestWrapper @inject IUserUtility UserUtility اطلاعات کلی اطلاعات کلی دسته بندی محصول را به دقت وارد کنید @* بستن *@ بستن @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()); await RestWrapper.CrudApiRest(Address.BrandController).Create(request, token); MudDialog.Close(DialogResult.Ok(true)); } catch (ApiException ex) { var exe = await ex.GetContentAsAsync(); 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; } } }