< Summary

Class:MUNity.BlazorServer.Components.Conference.Application.ApplyOnApplicationComponent
Assembly:MUNity.BlazorServer
File(s):C:\Users\aeuke\source\repos\PeerConradi\munity\src\MUNity.BlazorServer\Components\Conference\Application\ApplyOnApplicationComponent.razor
Covered lines:0
Uncovered lines:50
Coverable lines:50
Total lines:110
Line coverage:0% (0 of 50)
Covered branches:0
Total branches:18
Branch coverage:0% (0 of 18)
Covered methods:0
Total methods:4
Method coverage:0% (0 of 4)

Metrics

MethodBranch coverage Cyclomatic complexity Line coverage
BuildRenderTree(...)0%100%
get_ConferenceId()100%10%
get_AuthStateTask()100%10%
ApplyToSeelctedApplication()0%80%

File(s)

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

#LineLine coverage
 1@using MUNity.Database.Models.Conference
 2@using MUNity.Base
 3
 4@inject MUNity.Database.Context.MunityContext context
 5@inject UserManager<MUNity.Database.Models.User.MunityUser> userManager
 6
 07@if (!finished)
 08{
 9    <h3>Verfügbare Bewerbungen</h3>
 10
 11    <h5>Bewerbungen auf die man sich Bewerben kann:</h5>
 12    <div class="row">
 013        @foreach (var application in context.Fluent.ForConference(ConferenceId).ApplicationsWithFreeSlots()
 014         .Include(n => n.DelegationWishes)
 015         .ThenInclude(n => n.Delegation)
 016         .ThenInclude(n => n.Roles)
 017         .Include(n => n.Users))
 018        {
 19            <div class="col-4">
 20                <div class="card">
 21                    <div class="card-body">
 022                        <h4 class="card-title">@application.DelegationApplicationId</h4>
 023                        <p>@application.Expose</p>
 24                        <h6>Gewünschte Delegationen</h6>
 25                        <ul>
 026                            @foreach (var delegation in application.DelegationWishes)
 027                            {
 028                                <li>@delegation.Delegation.Name (@delegation.Delegation.Roles.Count verfügbare Plätze)</
 029                            }
 30                        </ul>
 031                        <h6>Anzahl BewerberInnen: @application.Users.Count(n => n.Status == DelegationApplicationUserEnt
 032                        <button class="btn btn-primary" @onclick="() => selectedApplication = application">Anfrage an di
 33                    </div>
 34                </div>
 35            </div>
 036        }
 37    </div>
 38
 039    @if (selectedApplication != null)
 040    {
 41        <div class="modal-backdrop opacity-5"></div>
 42        <div class="modal fade show" id="modal-dialog" style="display: block;" aria-modal="true" role="dialog">
 43            <div class="modal-dialog">
 44                <div class="modal-content">
 45                    <div class="modal-header">
 46                        <h4 class="modal-title">Modal Dialog</h4>
 047                        <button type="button" class="btn-close" @onclick="() => selectedApplication = null"></button>
 48                    </div>
 49                    <div class="modal-body">
 50                        <label>Nachricht</label>
 51                        <textarea class="form-control" @bind="this.message"></textarea>
 52                        <small>Hier können Sie eine kurze Nachricht eingeben, welche den anderen Teilnehmenden in dieser
 53                    </div>
 54                    <div class="modal-footer">
 055                        <a class="btn btn-white" @onclick="() => selectedApplication = null">Close</a>
 056                        <a href="javascript:;" class="btn btn-success" @onclick="() => ApplyToSeelctedApplication()">Act
 57                    </div>
 58                </div>
 59            </div>
 60        </div>
 061    }
 062}
 63else
 064            {
 65                <div class="row">
 66                    <div class="col-12">
 67                        <div class="alert alert-success"><b>Erfolgreich!</b> Ihre Anfrage wurde gespeichert.</div>
 68                    </div>
 69                </div>
 070            }
 71
 72
 73@code {
 074    [Parameter] public string ConferenceId { get; set; }
 75
 076    [CascadingParameter] public Task<AuthenticationState> AuthStateTask { get; set; }
 77
 78    private Database.Models.Conference.DelegationApplication selectedApplication;
 79
 80    private string message;
 81
 82    private bool finished;
 83
 84    private async Task ApplyToSeelctedApplication()
 085    {
 086        var claim = (await AuthStateTask)?.User;
 87
 088        if (claim != null && selectedApplication != null)
 089        {
 090            var user = await userManager.FindByNameAsync(claim.Identity.Name);
 091            if (user != null)
 092            {
 093                var entry = new DelegationApplicationUserEntry()
 094                {
 095                    User = user,
 096                    Application = selectedApplication,
 097                    Status = DelegationApplicationUserEntryStatuses.RequestJoining,
 098                    CanWrite = false,
 099                    Message = message
 0100                };
 101
 0102                context.DelegationApplicationUserEntries.Add(entry);
 0103                context.SaveChanges();
 104
 0105                selectedApplication = null;
 0106                finished = true;
 0107            }
 0108        }
 0109    }
 110}