< Summary

Information
Class: Syki.Front.Features.Academic.CreateCourse.CreateCourseDialog
Assembly: Front
File(s): /home/runner/work/syki/syki/Front/Features/Academic/CreateCourse/CreateCourseDialog.razor
Tag: 22_11348620282
Line coverage
0%
Covered lines: 0
Uncovered lines: 20
Coverable lines: 20
Total lines: 70
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 8
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/CreateCourse/CreateCourseDialog.razor

#LineLine coverage
 1@namespace Syki.Front.Features.Academic.CreateCourse
 2
 3<MudDialog Class="pb-2">
 4    <TitleContent>
 5        <SykiDialogTitle Text="Novo Curso" />
 6    </TitleContent>
 7    <DialogContent>
 08        <MudForm @ref="@_form" Class="pt-1">
 09            <SykiTextField Label="Nome" AutoFocus="true" @bind-Value="@_name" />
 010            <MudSelect
 011                Dense="true"
 012                Margin="Margin.Dense"
 013                Variant="Variant.Outlined"
 14                Class="mb-2"
 15                @bind-Value="@_type"
 16                Label="Tipo"
 17                Required="true"
 18                RequiredError="Informe!"
 19                AdornmentColor="Color.Primary
 20            ">
 021                @foreach (CourseType? item in Enum.GetValues<CourseType>())
 22                {
 23                    <MudSelectItem Value="@item">@item.GetDescription()</MudSelectItem>
 24                }
 25            </MudSelect>
 26        </MudForm>
 27    </DialogContent>
 28    <DialogActions>
 29        <DialogCancelButton OnClick="@Cancel" />
 30        <SykiProgressCircular Loading="@_loading" />
 31        <DialogSaveButton OnClick="@Submit" />
 32    </DialogActions>
 33</MudDialog>
 34
 35@inject ISnackbar Snackbar
 36@inject CreateCourseClient Client
 37
 38@code
 39{
 40    [CascadingParameter]
 041    MudDialogInstance MudDialog { get; set; }
 42
 43    private MudForm _form;
 44    private bool _loading;
 45    private string _name;
 46    private CourseType? _type;
 47
 48    async Task Submit()
 49    {
 050        if (_loading) return;
 51
 052        await _form.Validate();
 053        if (!_form.IsValid) return;
 54
 055        _loading = true;
 056        var response = await Client.Create(_name, _type!.Value);
 057        if (response.IsSuccess())
 58        {
 059            MudDialog.Close(DialogResult.Ok(true));
 060            Snackbar.Add("Curso cadastrado com sucesso!", Severity.Success);
 61        }
 62        else
 63        {
 064            Snackbar.Add(response.GetError().Message, Severity.Error);
 65        }
 066        _loading = false;
 067    }
 68
 069    void Cancel() => MudDialog.Cancel();
 70}

Methods/Properties

get_MudDialog()
Submit()
Cancel()