< Summary

Class:MUNity.BlazorServer.Components.Conference.Application.ApplicationReviewComponent
Assembly:MUNity.BlazorServer
File(s):C:\Users\aeuke\source\repos\PeerConradi\munity\src\MUNity.BlazorServer\Components\Conference\Application\ApplicationReviewComponent.razor
Covered lines:0
Uncovered lines:113
Coverable lines:113
Total lines:292
Line coverage:0% (0 of 113)
Covered branches:0
Total branches:78
Branch coverage:0% (0 of 78)
Covered methods:0
Total methods:10
Method coverage:0% (0 of 10)

Metrics

MethodBranch coverage Cyclomatic complexity Line coverage
BuildRenderTree(...)0%620%
get_Application()100%10%
get_ConferenceId()100%10%
get_ApplicationId()100%10%
get_AuthStateTask()100%10%
OnInitializedAsync()100%10%
LoadApplication()0%40%
OnParametersSetAsync()0%80%
FinishApplication()0%20%
SaveApplication()0%20%

File(s)

C:\Users\aeuke\source\repos\PeerConradi\munity\src\MUNity.BlazorServer\Components\Conference\Application\ApplicationReviewComponent.razor

#LineLine coverage
 1@inject MUNity.Database.Context.MunityContext context
 2
 3@page "/conference/application/review/{ApplicationId:int}"
 4
 05@if (Application != null && isAllowedAccess.Value)
 06{
 7    <div class="invoice">
 8        <!-- BEGIN invoice-company -->
 9        <div class="invoice-company">
 10            <span class="float-end hidden-print">
 011                @if (Application.DelegationApplicationId == 0)
 012                {
 13
 014                }
 015                @if (Application.Status == MUNity.Base.ApplicationStatuses.Writing && IsApproved)
 016                {
 017                    <button class="btn btn-outline-success mb-10px" @onclick="() => FinishApplication()">
 18                        <i class="fa fa-arrow-right t-plus-1 text-success fa-fw fa-lg"></i> Einreichen
 19                    </button>
 020                }
 021                else if (Application.Status == MUNity.Base.ApplicationStatuses.Writing && !IsApproved)
 022                {
 023                    <button class="btn btn-outline-info mb-10px" @onclick="() => SaveApplication()">
 24                        <i class="fa fa-save t-plus-1 fa-fw fa-lg"></i> Speichern
 25                    </button>
 026                }
 27
 28                @*<a href="javascript:;" class="btn btn-sm btn-white mb-10px"><i class="fa fa-file-pdf t-plus-1 text-dan
 29                    <a href="javascript:;" onclick="window.print()" class="btn btn-sm btn-white mb-10px"><i class="fa fa
 30            </span>
 31            Teilnahmebewerbung
 32        </div>
 33        <!-- END invoice-company -->
 34        <!-- BEGIN invoice-header -->
 35        <div class="invoice-header">
 36            <div class="invoice-from">
 37                <small>Von:</small>
 38                <address class="mt-5px mb-5px">
 39                    <strong class="text-inverse">BewerberInnen</strong><br>
 040                    @foreach (var user in this.Application.Users)
 041                    {
 042                        <span>@user.User.Forename @user.User.Lastname (@@@user.User.UserName)</span><br>
 043                    }
 44                </address>
 45
 46            </div>
 47
 48            <div class="invoice-to">
 49                <small>Für</small>
 050                @if (conference != null)
 051                {
 52                    <address class="mt-5px mb-5px">
 053                        <strong class="text-inverse">@conference.ConferenceShort</strong><br>
 054                        @conference.FullName<br>
 055                        @if (conference.StartDate != null && conference.EndDate != null)
 056                        {
 057                            <span>@conference.StartDate.Value.ToShortDateString() - @conference.EndDate.Value.ToShortDat
 058                        }<br>
 59                    </address>
 060                }
 61            </div>
 62
 63            <div class="invoice-date">
 64                <small>Bewerbungsinfo</small>
 065                <div class="date text-inverse mt-5px">@Application.ApplyDate.ToString("dd MMMM yyyy")</div>
 66                <div class="invoice-detail">
 067                    #@Application.DelegationApplicationId<br>
 68                    Delegationsbewerbung
 69                </div>
 70            </div>
 71        </div>
 72        <!-- END invoice-header -->
 73        <!-- BEGIN invoice-content -->
 74        <div class="invoice-content">
 75            <!-- BEGIN table-responsive -->
 76            <div class="table-responsive">
 77                <table class="table table-invoice">
 78                    <thead>
 79                        <tr>
 80                            <th width="5%">#</th>
 81                            <th>Delegationen</th>
 82                        </tr>
 83                    </thead>
 84                    <tbody>
 085                        @foreach (var delegationWish in Application.DelegationWishes)
 086                        {
 87                            <tr>
 088                                <td>#@Application.DelegationWishes.ToList().IndexOf(delegationWish)</td>
 89                                <td>
 090                                    <span class="text-inverse">@delegationWish.Delegation.Name</span><br>
 91                                </td>
 92                            </tr>
 093                        }
 94
 95                    </tbody>
 96                </table>
 97            </div>
 98            <!-- END table-responsive -->
 99            <!-- BEGIN invoice-price -->
 100            <div class="invoice-price">
 101                <div class="invoice-price-left">
 102                    <div class="invoice-price-row">
 103                        <div class="sub-price">
 104                            <small>Erfüllt Delegationsgröße</small>
 105                            <span class="@((sizeIsCorrect) ? "text-success" : "text-danger")"><i class="fa @((sizeIsCorr
 106                        </div>
 0107                        @if (!sizeIsCorrect)
 0108                        {
 109                            <div class="sub-price">
 110                                <i class="fa fa-plus text-muted"></i>
 111                            </div>
 112                            <div class="sub-price">
 113                                <small>Öffentlich</small>
 114                                <span class="@((Application.OpenToPublic) ? "text-success" : "text-danger")"><i class="f
 115                            </div>
 0116                        }
 117
 118                    </div>
 119                </div>
 0120                @if (IsApproved && Application.Status == MUNity.Base.ApplicationStatuses.Pending)
 0121                {
 122                    <div class="invoice-price-right bg-success">
 123                        <small>Status</small>
 124                        <span class="fw-bold">Gültig (eingereicht)</span>
 125                    </div>
 0126                }
 0127                else if (IsApproved && Application.Status == MUNity.Base.ApplicationStatuses.Writing)
 0128                {
 129                    <div class="invoice-price-right bg-warning">
 130                        <small>Status</small>
 131                        <span class="fw-bold">Gültig (nicht eingereicht)</span>
 132                    </div>
 0133                }
 0134                else if (!IsApproved && Application.Status == MUNity.Base.ApplicationStatuses.Pending)
 0135                {
 136                    <div class="invoice-price-right bg-danger">
 137                        <small>Status</small>
 138                        <span class="fw-bold">nicht gültig (eingereicht)</span>
 139                    </div>
 0140                }
 0141                else if (!IsApproved && Application.Status == MUNity.Base.ApplicationStatuses.Writing)
 0142                {
 143                    <div class="invoice-price-right bg-danger">
 144                        <small>Status</small>
 145                        <span class="fw-bold">nicht gültig (nicht eingereicht)</span>
 146                    </div>
 0147                }
 0148                else if (IsApproved && Application.Status == MUNity.Base.ApplicationStatuses.Saved)
 0149                {
 150                    <div class="invoice-price-right bg-info">
 151                        <small>Status</small>
 152                        <span class="fw-bold">Gültig (gespeichert)</span>
 153                    </div>
 0154                }
 0155                else if (!IsApproved && Application.Status == MUNity.Base.ApplicationStatuses.Saved)
 0156                {
 157                    <div class="invoice-price-right bg-warning">
 158                        <small>Status</small>
 159                        <span class="fw-bold">nicht gültig (gespeichert)</span>
 160                    </div>
 0161                }
 162
 163            </div>
 164            <!-- END invoice-price -->
 165        </div>
 166
 0167        @if (Application.DelegationApplicationId == 0)
 0168        {
 169            <div class="invoice-note">
 170                <div class="alert alert-warning">
 171                    Die Bewerbung wurde noch nicht gespeichert/eingereicht. Gehen Sie oben auf Speichern/Einreichen um d
 172                </div>
 173            </div>
 0174        }
 175
 176
 177        <div class="invoice-note">
 178            * Die zu der Bewerbung eingeladenen Benutzer müssen bis zum Ende der Anmeldephase die Bewerbung bestätigen. 
 179            * Bei Fragen zu Ihrer Anmeldung können Sie sich jederzeit an unsere Teilnehmendenbetreuung wenden.<br>
 180            * Sie können diese Bewerbung unter dem Menüpunkt ,,Meine Bewerbungen´´ jederzeit zurückziehen oder bearbeite
 181        </div>
 182
 183        <div class="invoice-footer">
 184            <p class="text-center mb-5px fw-bold">
 185                Danke für Ihre Bewerbung
 186            </p>
 187            <p class="text-center">
 188                <span class="me-10px"><i class="fa fa-fw fa-lg fa-globe"></i> munbw.de</span>
 189                <span class="me-10px"><i class="fa fa-fw fa-lg fa-phone-volume"></i> T:016-18192302</span>
 190                <span class="me-10px"><i class="fa fa-fw fa-lg fa-envelope"></i> teilnehmende@@munbw.de</span>
 191            </p>
 192        </div>
 193        <!-- END invoice-footer -->
 194    </div>
 0195}
 0196else if (!isAllowedAccess.Value)
 0197{
 198    <p>Keine Berechtigung diese Bewerbung zu sehen!</p>
 0199}
 200else
 0201{
 202    <p>Anmeldung wird geladen.</p>
 0203}
 204
 205
 206
 207@code {
 0208    [Parameter] public MUNity.Database.Models.Conference.DelegationApplication Application { get; set; }
 209
 0210    [Parameter] public string ConferenceId { get; set; }
 211
 0212    [Parameter] public int ApplicationId { get; set; }
 213
 0214    [CascadingParameter] Task<AuthenticationState> AuthStateTask { get; set; }
 215
 216    private bool? isAllowedAccess;
 217
 218    private bool IsApproved;
 219
 220    private bool sizeIsCorrect;
 221
 222    private MUNity.Database.Models.Conference.Conference conference;
 223
 224    protected override async Task OnInitializedAsync()
 0225    {
 0226        await base.OnInitializedAsync();
 227
 0228    }
 229
 230    private async Task LoadApplication()
 0231    {
 232
 0233        Application = await context.DelegationApplications
 0234            .Include(n => n.DelegationWishes)
 0235            .ThenInclude(n => n.Delegation)
 0236            .Include(n => n.Users)
 0237            .ThenInclude(n => n.User)
 0238            .FirstOrDefaultAsync(n => n.DelegationApplicationId == ApplicationId);
 239
 240
 0241        this.sizeIsCorrect = Application.DelegationWishes.All(n => context.Delegates.Count(a => a.Delegation.DelegationI
 242
 0243        this.IsApproved = this.sizeIsCorrect || (this.sizeIsCorrect && Application.OpenToPublic);
 244
 245
 0246        this.conference = context.Conferences.AsNoTracking().FirstOrDefault(n => n.ConferenceId == ConferenceId);
 247
 0248    }
 249
 250    protected override async Task OnParametersSetAsync()
 0251    {
 0252        await base.OnParametersSetAsync();
 0253        var claim = (await AuthStateTask)?.User;
 0254        if (claim == null)
 0255        {
 0256            this.isAllowedAccess = false;
 0257        }
 258        else
 0259        {
 0260            this.isAllowedAccess = await context.DelegationApplicationUserEntries
 0261                .AnyAsync(n => n.User.UserName == claim.Identity.Name && n.Application.DelegationApplicationId == Applic
 0262        }
 263
 0264        if (this.isAllowedAccess.HasValue && this.isAllowedAccess.Value)
 0265        {
 0266            await LoadApplication();
 0267        }
 0268    }
 269
 270    private void FinishApplication()
 0271    {
 0272        if (!this.context.DelegationApplications.Contains(Application))
 0273        {
 0274            this.context.DelegationApplications.Add(Application);
 275
 0276        }
 0277        Application.Status = MUNity.Base.ApplicationStatuses.Pending;
 0278        var recaff = this.context.SaveChanges();
 279
 0280    }
 281
 282    private void SaveApplication()
 0283    {
 0284        if (!this.context.DelegationApplications.Contains(Application))
 0285        {
 0286            this.context.DelegationApplications.Add(Application);
 0287        }
 0288        Application.Status = MUNity.Base.ApplicationStatuses.Saved;
 0289        var recaff = this.context.SaveChanges();
 290
 0291    }
 292}