| | 1 | | @using Microsoft.EntityFrameworkCore |
| | 2 | | @using MUNity.Schema.Conference |
| | 3 | |
|
| | 4 | | @inject Services.UserService userSerivce |
| | 5 | | @inject Services.ConferenceApplicationService applicationService |
| | 6 | | @inject Database.Context.MunityContext context |
| | 7 | | @inject NotificationService notificationService |
| | 8 | |
|
| 0 | 9 | | @if (Application != null) |
| 0 | 10 | | { |
| | 11 | |
|
| 0 | 12 | | @if (searchResult != null) |
| 0 | 13 | | { |
| | 14 | | <div class="row"> |
| 0 | 15 | | @if (searchResult.Status == FindUserForApplicationResult.ResultStatuses.AlreadyApplying) |
| 0 | 16 | | { |
| | 17 | | <div class="alert alert-warning">Der/Die eigebene BenutzerIn kann nicht zur Bewerbung hinzugefügt werden |
| 0 | 18 | | } |
| 0 | 19 | | else if (searchResult.Status == FindUserForApplicationResult.ResultStatuses.AlreadyParticipating) |
| 0 | 20 | | { |
| | 21 | | <div class="alert alert-warning">Der/Die eingebene BenutzerIn kann nicht zur Bewerbung hinzugefügt werde |
| 0 | 22 | | } |
| 0 | 23 | | else if (searchResult.Status == FindUserForApplicationResult.ResultStatuses.NoUserFound) |
| 0 | 24 | | { |
| | 25 | | <div class="alert alert-info"> |
| | 26 | | Der/Die eingebene BenuterIn ist diesem System nicht bekannt. Sollten Sie wissen, dass diese Person k |
| 0 | 27 | | <button class="btn btn-default" @onclick="() => AddShadowUser(searchInput)">Einladen.</button> Danac |
| | 28 | | Teilnehmenden dieser Bewerbung auch ein entsprechendes Konto benötigen. |
| | 29 | | </div> |
| 0 | 30 | | } |
| | 31 | | </div> |
| 0 | 32 | | } |
| | 33 | |
|
| | 34 | | <div class="row profile-content"> |
| | 35 | | <div class="table-responsive form-inline"> |
| | 36 | | <table class="table table-profile align-middle"> |
| | 37 | | <thead> |
| | 38 | | <tr> |
| | 39 | | <th></th> |
| | 40 | | <th> |
| | 41 | | <h4>BenutzerInnen <small>An dieser Stelle können Personen zu der Bewerbung hinzugefügt werden.</small></h4 |
| | 42 | | </th> |
| | 43 | | </tr> |
| | 44 | | </thead> |
| | 45 | | <tbody> |
| 0 | 46 | | @foreach(var user in Application.Users) |
| 0 | 47 | | { |
| | 48 | | <ApplicationUserComponent User="@user" RemoveUser=RemoveUser /> |
| 0 | 49 | | } |
| | 50 | |
|
| | 51 | | <tr> |
| | 52 | | <td class="field">Einladen</td> |
| | 53 | | <td> |
| | 54 | | <div class="input-group"> |
| | 55 | | <div class="input-group-text">@@</div> |
| | 56 | | <input type="text" class="form-control" @bind="searchInput"> |
| 0 | 57 | | <button type="button" class="btn btn-indigo" @onclick="() => SearchUser()">Hinzufügen</b |
| | 58 | | </div> |
| | 59 | | </td> |
| | 60 | | </tr> |
| | 61 | | <tr class="divider highlight"> |
| | 62 | | <td colspan="2"></td> |
| | 63 | | </tr> |
| | 64 | |
|
| | 65 | | <tr> |
| | 66 | | <td class="field">Lehrkraft</td> |
| | 67 | | <td> |
| | 68 | | <RadzenCheckBox TValue="bool" @bind-Value="@guestsConverted" Name="WithTeacherCheckBox" /> |
| | 69 | | <RadzenLabel Text="Delegation mit Lehrkraft" Component="WithTeacherCheckBox" /> |
| | 70 | | </td> |
| | 71 | | </tr> |
| | 72 | |
|
| | 73 | | <tr> |
| | 74 | | <td></td> |
| | 75 | | <td> |
| | 76 | | <small> |
| | 77 | | Sofern Sie mit einer Lehrkraft kommen, geben Sie dies bitte hier an. Die Lehrkraft brauc |
| | 78 | | Diese wird später durch ein dazu berechtigtes Teammitglied nach Annahme der Bewerbung in |
| | 79 | | </small> |
| | 80 | | </td> |
| | 81 | | </tr> |
| | 82 | |
|
| | 83 | |
|
| | 84 | | <tr class="divider"> |
| | 85 | | <td colspan="2"></td> |
| | 86 | | </tr> |
| | 87 | |
|
| | 88 | |
|
| | 89 | | <tr> |
| | 90 | | <td class="field">Offene Bewerbung</td> |
| | 91 | | <td> |
| | 92 | | <RadzenCheckBox TValue="bool" @bind-Value="@Application.OpenToPublic" Name="OpenToPublicChec |
| | 93 | | <RadzenLabel Text="offene Bewerbung" Component="OpenToPublicCheckBox" /> |
| | 94 | | </td> |
| | 95 | | </tr> |
| | 96 | |
|
| | 97 | | <tr> |
| | 98 | | <td></td> |
| | 99 | | <td> |
| | 100 | | <small> |
| | 101 | | Wenn Sie die Bewerbung für andere öffnen, können sich diese Benutzer auf ihre Bewerbung/ |
| | 102 | | Diese Funktion ist dann praktisch, wenn Sie mit ihrer momentanen Gruppe ihre Wunschdeleg |
| | 103 | | </small> |
| | 104 | | </td> |
| | 105 | | </tr> |
| | 106 | |
|
| | 107 | | <tr> |
| | 108 | | <td class="field">Expose</td> |
| | 109 | | <td> |
| | 110 | | <RadzenTextArea class="form-control" Disabled="@(!Application.OpenToPublic)" @bind-Value="@A |
| | 111 | | </td> |
| | 112 | | </tr> |
| | 113 | |
|
| | 114 | |
|
| | 115 | | <tr class="highlight"> |
| | 116 | | <td class="field"> </td> |
| | 117 | | <td class=""> |
| 0 | 118 | | <button type="submit" class="btn btn-primary" @onclick="() => UsersSelected.InvokeAsync()">Weiter zur Dele |
| | 119 | | </td> |
| | 120 | | </tr> |
| | 121 | | </tbody> |
| | 122 | | </table> |
| | 123 | | </div> |
| | 124 | | </div> |
| 0 | 125 | | } |
| | 126 | | else |
| 0 | 127 | | { |
| | 128 | | <div class="alert alert-warning">Error detected: There is no Application given to this component. Try to reload the |
| 0 | 129 | | } |
| | 130 | |
|
| | 131 | |
|
| | 132 | | @code { |
| | 133 | |
|
| 0 | 134 | | [Parameter] public EventCallback UsersSelected { get; set; } |
| | 135 | |
|
| 0 | 136 | | [Parameter] public string ConferenceId { get; set; } |
| | 137 | |
|
| 0 | 138 | | [Parameter] public MUNity.Database.Models.Conference.DelegationApplication Application { get; set; } |
| | 139 | |
|
| | 140 | | private bool guestsConverted |
| | 141 | | { |
| 0 | 142 | | get => Application.GuestsCount != null && Application.GuestsCount.Value > 0; |
| | 143 | | set |
| 0 | 144 | | { |
| 0 | 145 | | if (value) |
| 0 | 146 | | Application.GuestsCount = 1; |
| | 147 | | else |
| 0 | 148 | | Application.GuestsCount = null; |
| 0 | 149 | | } |
| | 150 | | } |
| | 151 | |
|
| | 152 | | private FindUserForApplicationResult searchResult; |
| | 153 | |
|
| | 154 | | private string searchInput; |
| | 155 | |
|
| | 156 | | private void SearchUser() |
| 0 | 157 | | { |
| 0 | 158 | | searchResult = applicationService.FindUserToAddToDelegationApplication(searchInput, ConferenceId); |
| 0 | 159 | | if (searchResult.Status == FindUserForApplicationResult.ResultStatuses.CanBeAdded) |
| 0 | 160 | | { |
| 0 | 161 | | AddUser(searchResult.UserName); |
| 0 | 162 | | } |
| 0 | 163 | | } |
| | 164 | |
|
| | 165 | | private void AddUser(string username) |
| 0 | 166 | | { |
| 0 | 167 | | var user = userSerivce.GetUserByUsername(searchResult.UserName); |
| 0 | 168 | | if (user == null) |
| 0 | 169 | | { |
| 0 | 170 | | notificationService.Notify(NotificationSeverity.Error, "Benutzer nicht gefunden", $"Es wurde kein Benutzer m |
| 0 | 171 | | } |
| | 172 | | else |
| 0 | 173 | | { |
| 0 | 174 | | if (Application.Users.All(n => n.User.UserName != user.UserName)) |
| 0 | 175 | | { |
| 0 | 176 | | Application.Users.Add(new Database.Models.Conference.DelegationApplicationUserEntry() |
| 0 | 177 | | { |
| 0 | 178 | | Application = this.Application, |
| 0 | 179 | | CanWrite = false, |
| 0 | 180 | | Message = "Sie wurden eingeladen durch den/die Erstellerin dieser Anmeldung", |
| 0 | 181 | | Status = DelegationApplicationUserEntryStatuses.Invited, |
| 0 | 182 | | User = user |
| 0 | 183 | | }); |
| | 184 | |
|
| 0 | 185 | | this.searchInput = ""; |
| 0 | 186 | | this.searchResult = null; |
| 0 | 187 | | } |
| | 188 | | else |
| 0 | 189 | | { |
| 0 | 190 | | notificationService.Notify(NotificationSeverity.Warning, "Bereits vorhaden", "Die angegebene Person ist |
| 0 | 191 | | } |
| 0 | 192 | | } |
| | 193 | |
|
| | 194 | |
|
| 0 | 195 | | } |
| | 196 | |
|
| | 197 | | private async Task AddShadowUser(string mail) |
| 0 | 198 | | { |
| 0 | 199 | | var shadowUser = await userSerivce.CreateShadowUser(mail); |
| 0 | 200 | | if (shadowUser != null) |
| 0 | 201 | | { |
| 0 | 202 | | Application.Users.Add(new Database.Models.Conference.DelegationApplicationUserEntry() |
| 0 | 203 | | { |
| 0 | 204 | | Application = this.Application, |
| 0 | 205 | | CanWrite = false, |
| 0 | 206 | | Message = "Sie wurden eingeladen durch den/die Erstellerin dieser Anmeldung", |
| 0 | 207 | | Status = DelegationApplicationUserEntryStatuses.Invited, |
| 0 | 208 | | User = shadowUser |
| 0 | 209 | | }); |
| | 210 | |
|
| | 211 | | // Send a Mail |
| | 212 | |
|
| 0 | 213 | | this.searchResult = null; |
| 0 | 214 | | this.searchInput = ""; |
| | 215 | |
|
| 0 | 216 | | await this.InvokeAsync(StateHasChanged); |
| 0 | 217 | | } |
| | 218 | | else |
| 0 | 219 | | { |
| 0 | 220 | | notificationService.Notify(NotificationSeverity.Error, "Einladung fehlgeschlagen", "Die Einladung des Benutz |
| 0 | 221 | | } |
| 0 | 222 | | } |
| | 223 | |
|
| | 224 | | private async Task RemoveUser(Database.Models.Conference.DelegationApplicationUserEntry user) |
| 0 | 225 | | { |
| 0 | 226 | | this.Application.Users.Remove(user); |
| 0 | 227 | | } |
| | 228 | |
|
| | 229 | |
|
| | 230 | | } |