| | 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 | |
|
| 0 | 7 | | @if (!finished) |
| 0 | 8 | | { |
| | 9 | | <h3>Verfügbare Bewerbungen</h3> |
| | 10 | |
|
| | 11 | | <h5>Bewerbungen auf die man sich Bewerben kann:</h5> |
| | 12 | | <div class="row"> |
| 0 | 13 | | @foreach (var application in context.Fluent.ForConference(ConferenceId).ApplicationsWithFreeSlots() |
| 0 | 14 | | .Include(n => n.DelegationWishes) |
| 0 | 15 | | .ThenInclude(n => n.Delegation) |
| 0 | 16 | | .ThenInclude(n => n.Roles) |
| 0 | 17 | | .Include(n => n.Users)) |
| 0 | 18 | | { |
| | 19 | | <div class="col-4"> |
| | 20 | | <div class="card"> |
| | 21 | | <div class="card-body"> |
| 0 | 22 | | <h4 class="card-title">@application.DelegationApplicationId</h4> |
| 0 | 23 | | <p>@application.Expose</p> |
| | 24 | | <h6>Gewünschte Delegationen</h6> |
| | 25 | | <ul> |
| 0 | 26 | | @foreach (var delegation in application.DelegationWishes) |
| 0 | 27 | | { |
| 0 | 28 | | <li>@delegation.Delegation.Name (@delegation.Delegation.Roles.Count verfügbare Plätze)</ |
| 0 | 29 | | } |
| | 30 | | </ul> |
| 0 | 31 | | <h6>Anzahl BewerberInnen: @application.Users.Count(n => n.Status == DelegationApplicationUserEnt |
| 0 | 32 | | <button class="btn btn-primary" @onclick="() => selectedApplication = application">Anfrage an di |
| | 33 | | </div> |
| | 34 | | </div> |
| | 35 | | </div> |
| 0 | 36 | | } |
| | 37 | | </div> |
| | 38 | |
|
| 0 | 39 | | @if (selectedApplication != null) |
| 0 | 40 | | { |
| | 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> |
| 0 | 47 | | <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"> |
| 0 | 55 | | <a class="btn btn-white" @onclick="() => selectedApplication = null">Close</a> |
| 0 | 56 | | <a href="javascript:;" class="btn btn-success" @onclick="() => ApplyToSeelctedApplication()">Act |
| | 57 | | </div> |
| | 58 | | </div> |
| | 59 | | </div> |
| | 60 | | </div> |
| 0 | 61 | | } |
| 0 | 62 | | } |
| | 63 | | else |
| 0 | 64 | | { |
| | 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> |
| 0 | 70 | | } |
| | 71 | |
|
| | 72 | |
|
| | 73 | | @code { |
| 0 | 74 | | [Parameter] public string ConferenceId { get; set; } |
| | 75 | |
|
| 0 | 76 | | [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() |
| 0 | 85 | | { |
| 0 | 86 | | var claim = (await AuthStateTask)?.User; |
| | 87 | |
|
| 0 | 88 | | if (claim != null && selectedApplication != null) |
| 0 | 89 | | { |
| 0 | 90 | | var user = await userManager.FindByNameAsync(claim.Identity.Name); |
| 0 | 91 | | if (user != null) |
| 0 | 92 | | { |
| 0 | 93 | | var entry = new DelegationApplicationUserEntry() |
| 0 | 94 | | { |
| 0 | 95 | | User = user, |
| 0 | 96 | | Application = selectedApplication, |
| 0 | 97 | | Status = DelegationApplicationUserEntryStatuses.RequestJoining, |
| 0 | 98 | | CanWrite = false, |
| 0 | 99 | | Message = message |
| 0 | 100 | | }; |
| | 101 | |
|
| 0 | 102 | | context.DelegationApplicationUserEntries.Add(entry); |
| 0 | 103 | | context.SaveChanges(); |
| | 104 | |
|
| 0 | 105 | | selectedApplication = null; |
| 0 | 106 | | finished = true; |
| 0 | 107 | | } |
| 0 | 108 | | } |
| 0 | 109 | | } |
| | 110 | | } |