| | 1 | | @namespace Syki.Front.Features.Academic.UpdateCampus |
| | 2 | |
|
| | 3 | | <MudDialog Class="pb-2"> |
| | 4 | | <TitleContent> |
| | 5 | | <SykiDialogTitle Icon="@Icons.Material.Outlined.Edit" Text="Editar Campus" /> |
| | 6 | | </TitleContent> |
| | 7 | | <DialogContent> |
| 0 | 8 | | <MudForm @ref="@_form" Class="pt-1"> |
| 0 | 9 | | <SykiTextField Label="Nome" AutoFocus="true" @bind-Value="@Campus.Name" /> |
| 0 | 10 | | <SykiTextField Label="Cidade" @bind-Value="@Campus.City" /> |
| 0 | 11 | | </MudForm> |
| 0 | 12 | | </DialogContent> |
| 0 | 13 | | <DialogActions> |
| | 14 | | <DialogCancelButton OnClick="@Cancel" /> |
| | 15 | | <SykiProgressCircular Loading="@_loading" /> |
| | 16 | | <DialogSaveButton OnClick="@Submit" /> |
| | 17 | | </DialogActions> |
| | 18 | | </MudDialog> |
| | 19 | |
|
| | 20 | | @inject ISnackbar Snackbar |
| | 21 | | @inject UpdateCampusClient Client |
| | 22 | |
|
| | 23 | | @code |
| | 24 | | { |
| | 25 | | [CascadingParameter] |
| 0 | 26 | | MudDialogInstance MudDialog { get; set; } |
| | 27 | |
|
| | 28 | | [Parameter] |
| 0 | 29 | | public CampusOut Campus { get; set; } |
| | 30 | |
|
| | 31 | | private MudForm _form; |
| | 32 | | private bool _loading; |
| | 33 | |
|
| | 34 | | async Task Submit() |
| | 35 | | { |
| 0 | 36 | | if (_loading) return; |
| | 37 | |
|
| 0 | 38 | | await _form.Validate(); |
| 0 | 39 | | if (!_form.IsValid) return; |
| | 40 | |
|
| 0 | 41 | | _loading = true; |
| 0 | 42 | | var response = await Client.Update(Campus.Id, Campus.Name, Campus.City); |
| 0 | 43 | | if (response.IsSuccess()) |
| | 44 | | { |
| 0 | 45 | | MudDialog.Close(DialogResult.Ok(true)); |
| 0 | 46 | | Snackbar.Add("Campus editado com sucesso!", Severity.Success); |
| | 47 | | } |
| | 48 | | else |
| | 49 | | { |
| 0 | 50 | | Snackbar.Add(response.GetError().Message, Severity.Error); |
| | 51 | | } |
| 0 | 52 | | _loading = false; |
| 0 | 53 | | } |
| | 54 | |
|
| 0 | 55 | | void Cancel() => MudDialog.Cancel(); |
| | 56 | | } |