< Summary

Information
Class: Syki.Front.Features.Academic.UpdateCampus.UpdateCampusDialog
Assembly: Front
File(s): /home/runner/work/syki/syki/Front/Features/Academic/UpdateCampus/UpdateCampusDialog.razor
Tag: 22_11348620282
Line coverage
0%
Covered lines: 0
Uncovered lines: 20
Coverable lines: 20
Total lines: 56
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 6
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_MudDialog()100%210%
get_Campus()100%210%
Submit()0%4260%
Cancel()100%210%

File(s)

/home/runner/work/syki/syki/Front/Features/Academic/UpdateCampus/UpdateCampusDialog.razor

#LineLine coverage
 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>
 08        <MudForm @ref="@_form" Class="pt-1">
 09            <SykiTextField Label="Nome" AutoFocus="true" @bind-Value="@Campus.Name" />
 010            <SykiTextField Label="Cidade" @bind-Value="@Campus.City" />
 011        </MudForm>
 012    </DialogContent>
 013    <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]
 026    MudDialogInstance MudDialog { get; set; }
 27
 28    [Parameter]
 029    public CampusOut Campus { get; set; }
 30
 31    private MudForm _form;
 32    private bool _loading;
 33
 34    async Task Submit()
 35    {
 036        if (_loading) return;
 37
 038        await _form.Validate();
 039        if (!_form.IsValid) return;
 40
 041        _loading = true;
 042        var response = await Client.Update(Campus.Id, Campus.Name, Campus.City);
 043        if (response.IsSuccess())
 44        {
 045            MudDialog.Close(DialogResult.Ok(true));
 046            Snackbar.Add("Campus editado com sucesso!", Severity.Success);
 47        }
 48        else
 49        {
 050            Snackbar.Add(response.GetError().Message, Severity.Error);
 51        }
 052        _loading = false;
 053    }
 54
 055    void Cancel() => MudDialog.Cancel();
 56}