< Summary

Information
Class: Syki.Front.Features.Academic.CreateTeacher.CreateTeacherDialog
Assembly: Front
File(s): /home/runner/work/syki/syki/Front/Features/Academic/CreateTeacher/CreateTeacherDialog.razor
Tag: 22_11348620282
Line coverage
0%
Covered lines: 0
Uncovered lines: 19
Coverable lines: 19
Total lines: 81
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/CreateTeacher/CreateTeacherDialog.razor

#LineLine coverage
 1@namespace Syki.Front.Features.Academic.CreateTeacher
 2
 3<MudDialog Class="pb-2">
 4    <TitleContent>
 5        <MudText Typo="Typo.h6">
 6            <MudIcon Icon="@Icons.Material.Filled.Add" Class="mr-1 mb-n1" />
 7            Novo Professor
 8        </MudText>
 9    </TitleContent>
 10    <DialogContent>
 011        <MudForm @ref="@_form" Class="pt-1">
 012            <MudTextField
 013                OnlyValidateIfDirty="true"
 014                Immediate="true"
 015                Margin="Margin.Dense"
 016                Variant="Variant.Outlined"
 17                Class="pb-2"
 18                AutoFocus="true"
 19                @bind-Value="@_name"
 20                T="String"
 21                Label="Nome"
 22                Required="true"
 23                RequiredError="Informe!"
 24            />
 25            <MudTextField
 26                OnlyValidateIfDirty="true"
 27                Immediate="true"
 28                Margin="Margin.Dense"
 29                Variant="Variant.Outlined"
 30                Class="mb-2"
 31                @bind-Value="@_email"
 32                T="String"
 33                Label="Email"
 34                Required="true"
 35                RequiredError="Informe!"
 36            />
 37        </MudForm>
 38    </DialogContent>
 39    <DialogActions>
 40        <DialogCancelButton OnClick="@Cancel" />
 41        <SykiProgressCircular Loading="@_loading" />
 42        <DialogSaveButton OnClick="@Submit" />
 43    </DialogActions>
 44</MudDialog>
 45
 46@inject ISnackbar Snackbar
 47@inject CreateTeacherClient Client
 48
 49@code
 50{
 51    [CascadingParameter]
 052    MudDialogInstance MudDialog { get; set; }
 53
 54    private MudForm _form;
 55    private bool _loading;
 56    private string _name;
 57    private string _email;
 58
 59    async Task Submit()
 60    {
 061        if (_loading) return;
 62
 063        await _form.Validate();
 064        if (!_form.IsValid) return;
 65
 066        _loading = true;
 067        var response = await Client.Create(_name, _email);
 068        if (response.IsSuccess())
 69        {
 070            MudDialog.Close(DialogResult.Ok(true));
 071            Snackbar.Add("Professor cadastrado com sucesso!", Severity.Success);
 72        }
 73        else
 74        {
 075            Snackbar.Add(response.GetError().Message, Severity.Error);
 76        }
 077        _loading = false;
 078    }
 79
 080    void Cancel() => MudDialog.Cancel();
 81}

Methods/Properties

get_MudDialog()
Submit()
Cancel()