| | 1 | | @namespace Syki.Front.Features.Academic.UpdateCampus |
| | 2 | |
|
| | 3 | | <MudDialog Class="pb-2" DefaultFocus="DefaultFocus.None"> |
| | 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 | |
|
| 0 | 11 | | <MudSelect |
| 0 | 12 | | Dense="true" |
| 0 | 13 | | Margin="Margin.Dense" |
| | 14 | | Variant="Variant.Outlined" |
| | 15 | | T="BrazilState" |
| | 16 | | @bind-Value="@Campus.State" |
| | 17 | | Label="Estado" |
| | 18 | | Class="pb-2" |
| | 19 | | Required="true" |
| | 20 | | RequiredError="Informe!" |
| | 21 | | AdornmentColor="Color.Primary" |
| | 22 | | > |
| 0 | 23 | | @foreach (BrazilState type in Enum.GetValues<BrazilState>()) |
| | 24 | | { |
| 0 | 25 | | <MudSelectItem Value="@type">@type.GetDescription()</MudSelectItem> |
| | 26 | | } |
| | 27 | | </MudSelect> |
| | 28 | |
|
| | 29 | | <SykiTextField Label="Cidade" @bind-Value="@Campus.City" /> |
| | 30 | |
|
| | 31 | | <MudNumericField |
| | 32 | | MaxLength="5" |
| | 33 | | HideSpinButtons="true" |
| | 34 | | Margin="Margin.Dense" |
| | 35 | | Variant="Variant.Outlined" |
| | 36 | | @bind-Value="@Campus.Capacity" |
| | 37 | | Label="Capacidade" |
| | 38 | | Required="true" |
| | 39 | | Min="1" |
| | 40 | | RequiredError="Informe!" |
| | 41 | | /> |
| | 42 | | </MudForm> |
| | 43 | | </DialogContent> |
| | 44 | | <DialogActions> |
| | 45 | | <DialogCancelButton OnClick="@Cancel" /> |
| | 46 | | <SykiProgressCircular Loading="@_loading" /> |
| | 47 | | <DialogSaveButton OnClick="@Submit" /> |
| | 48 | | </DialogActions> |
| | 49 | | </MudDialog> |
| | 50 | |
|
| | 51 | | @inject ISnackbar Snackbar |
| | 52 | | @inject UpdateCampusClient Client |
| | 53 | |
|
| | 54 | | @code |
| | 55 | | { |
| | 56 | | [CascadingParameter] |
| 0 | 57 | | IMudDialogInstance MudDialog { get; set; } |
| | 58 | |
|
| | 59 | | [Parameter] |
| 0 | 60 | | public CampusOut Campus { get; set; } |
| | 61 | |
|
| | 62 | | private MudForm _form; |
| | 63 | | private bool _loading; |
| | 64 | |
|
| | 65 | | async Task Submit() |
| | 66 | | { |
| 0 | 67 | | if (_loading) return; |
| | 68 | |
|
| 0 | 69 | | await _form.Validate(); |
| 0 | 70 | | if (!_form.IsValid) return; |
| | 71 | |
|
| 0 | 72 | | _loading = true; |
| 0 | 73 | | var response = await Client.Update(Campus.Id, Campus.Name, Campus.State, Campus.City, Campus.Capacity); |
| 0 | 74 | | if (response.IsSuccess) |
| | 75 | | { |
| 0 | 76 | | MudDialog.Close(DialogResult.Ok(true)); |
| 0 | 77 | | Snackbar.Add("Campus editado com sucesso!", Severity.Success); |
| | 78 | | } |
| | 79 | | else |
| | 80 | | { |
| 0 | 81 | | Snackbar.Add(response.Error.Message, Severity.Error); |
| | 82 | | } |
| 0 | 83 | | _loading = false; |
| 0 | 84 | | } |
| | 85 | |
|
| 0 | 86 | | void Cancel() => MudDialog.Cancel(); |
| | 87 | | } |