< Summary

Information
Class: Syki.Front.Features.Academic.CreateCampus.CreateCampusDialog
Assembly: Front
File(s): /home/runner/work/syki/syki/Front/Features/Academic/CreateCampus/CreateCampusDialog.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%
Submit()0%4260%
Cancel()100%210%

File(s)

/home/runner/work/syki/syki/Front/Features/Academic/CreateCampus/CreateCampusDialog.razor

#LineLine coverage
 1@namespace Syki.Front.Features.Academic.CreateCampus
 2
 3<MudDialog Class="pb-2">
 4    <TitleContent>
 5        <SykiDialogTitle Text="Novo Campus" />
 6    </TitleContent>
 7    <DialogContent>
 08        <MudForm @ref="@_form">
 09            <SykiTextField Label="Nome" AutoFocus="true" @bind-Value="@_name" />
 010            <SykiTextField Label="Cidade" @bind-Value="@_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 CreateCampusClient Client
 22
 23@code
 24{
 25    [CascadingParameter]
 026    MudDialogInstance MudDialog { get; set; }
 27
 28    private MudForm _form;
 29    private bool _loading;
 30    private string _name;
 31    private string _city;
 32
 33    private async Task Submit()
 34    {
 035        if (_loading) return;
 36
 037        await _form.Validate();
 038        if (!_form.IsValid) return;
 39
 040        _loading = true;
 041        var response = await Client.Create(_name, _city);
 042        if (response.IsSuccessStatusCode)
 43        {
 044            MudDialog.Close(DialogResult.Ok(true));
 045            Snackbar.Add("Campus cadastrado com sucesso!", Severity.Success);
 46        }
 47        else
 48        {
 049            var error = await response.ToError();
 050            Snackbar.Add(error.Message, Severity.Error);
 51        }
 052        _loading = false;
 053    }
 54
 055    private void Cancel() => MudDialog.Cancel();
 56}

Methods/Properties

get_MudDialog()
Submit()
Cancel()