private static string GetCandidateAlert(CheckInOutRequest request, IImmutableList <CheckInOutCandidate> checkInOutCandidates, out AlertLevel level) { var text = ""; level = AlertLevel.Info; if (request.CheckType != CheckType.CheckOut) { return(text); } if (checkInOutCandidates.Any(predicate: c => !c.MayLeaveAlone)) { text = "Kinder mit gelbem Hintergrund dürfen nicht alleine gehen"; level = AlertLevel.Warning; } if (!checkInOutCandidates.Any(predicate: c => c.HasPeopleWithoutPickupPermission)) { return(text); } text = "Bei Kindern mit rotem Hintergrund gibt es Personen, die nicht abholberechtigt sind"; level = AlertLevel.Danger; return(text); }
private static async Task <CheckInOutResult> SendRequest( string securityCode, IImmutableList <int> selectedLocationIds, bool isFastCheckInOut, CheckInOutController controller ) { var request = new CheckInOutRequest { SecurityCode = securityCode, EventId = 389697, SelectedLocationGroupIds = selectedLocationIds, IsFastCheckInOut = isFastCheckInOut, CheckType = CheckType.CheckIn, CheckInOutCandidates = ImmutableList <CheckInOutCandidate> .Empty, FilterLocations = true }; var actionResult = await controller.GetPeople(request : request); var okResult = actionResult as OkObjectResult; var checkInOutResult = okResult !.Value as CheckInOutResult; return(checkInOutResult !); }
public async Task <IActionResult> ManualCheckIn([FromBody] CheckInOutRequest request) { var attendanceIds = request.CheckInOutCandidates.Select(selector: c => c.AttendanceId).ToImmutableList(); var success = await _checkInOutService.CheckInOutPeople(checkType : request.CheckType, attendanceIds : attendanceIds); var names = request.CheckInOutCandidates.Select(selector: c => c.Name).ToImmutableList(); if (success) { return(Ok(value: new CheckInOutResult { Text = $"{request.CheckType.ToString()} für ({request.SecurityCode}) {string.Join(separator: ", ", values: names)} war erfolgreich.", AlertLevel = AlertLevel.Success, AttendanceIds = attendanceIds })); } return(Ok(value: new CheckInOutResult { Text = $"{request.CheckType.ToString()} für ({request.SecurityCode}) {string.Join(separator: ", ", values: names)} ist fehlgeschlagen", AlertLevel = AlertLevel.Danger })); }
public async Task <IActionResult> GetPeople([FromBody] CheckInOutRequest request) { _taskManagementService.ActivateBackgroundTasks(); switch (request.FilterLocations) { case false when request.CheckType != CheckType.CheckIn: return(Ok(value: new CheckInOutResult { Text = "Suche ohne Location Filter ist nur bei CheckIn erlaubt.", AlertLevel = AlertLevel.Danger })); case true when request.SelectedLocationGroupIds.Count == 0: return(Ok(value: new CheckInOutResult { Text = "Bitte Locations auswählen.", AlertLevel = AlertLevel.Danger })); } if (request.SecurityCode.StartsWith(value: '1') && request.CheckType == CheckType.CheckIn) { await _checkInOutService.CreateUnregisteredGuest( requestSecurityCode : request.SecurityCode, requestEventId : request.EventId, requestSelectedLocationIds : request.SelectedLocationGroupIds); } var peopleSearchParameters = new PeopleSearchParameters( securityCode: request.SecurityCode, eventId: request.EventId, locationGroups: request.SelectedLocationGroupIds, useFilterLocationGroups: request.FilterLocations); var people = await _checkInOutService.SearchForPeople( searchParameters : peopleSearchParameters).ConfigureAwait(continueOnCapturedContext: false); await _searchLoggingService.LogSearch(peopleSearchParameters : peopleSearchParameters, people : people, deviceGuid : request.Guid, checkType : request.CheckType, filterLocations : request.FilterLocations); if (people.Count == 0) { return(Ok(value: new CheckInOutResult { Text = $"Es wurde niemand mit SecurityCode {request.SecurityCode} gefunden. Locations Filter überprüfen.", AlertLevel = AlertLevel.Danger, FilteredSearchUnsuccessful = true })); } var peopleReadyForProcessing = GetPeopleInRequestedState(people: people, checkType: request.CheckType); if (peopleReadyForProcessing.Count == 0) { return(Ok(value: new CheckInOutResult { Text = $"Niemand mit {request.SecurityCode} ist bereit für {request.CheckType.ToString()}. CheckIn/Out Einstellungen überprüfen.", AlertLevel = AlertLevel.Warning, FilteredSearchUnsuccessful = true })); } if (request.IsFastCheckInOut && request.FilterLocations && (!peopleReadyForProcessing.Any(predicate: p => !p.MayLeaveAlone || p.HasPeopleWithoutPickupPermission) || request.CheckType == CheckType.CheckIn)) { var kid = await TryFastCheckInOut(people : peopleReadyForProcessing, checkType : request.CheckType).ConfigureAwait(continueOnCapturedContext: false); if (kid != null) { return(Ok(value: new CheckInOutResult { Text = $"{request.CheckType.ToString()} für ({request.SecurityCode}) {kid.FirstName} {kid.LastName} war erfolgreich.", AlertLevel = AlertLevel.Success, SuccessfulFastCheckout = true, AttendanceIds = ImmutableList.Create(item: kid.AttendanceId) })); } } var checkInOutCandidates = peopleReadyForProcessing.Select(selector: p => new CheckInOutCandidate { AttendanceId = p.AttendanceId, Name = $"{p.FirstName} {p.LastName}", LocationId = p.LocationGroupId, MayLeaveAlone = p.MayLeaveAlone, HasPeopleWithoutPickupPermission = p.HasPeopleWithoutPickupPermission }).ToImmutableList(); var text = GetCandidateAlert(request: request, checkInOutCandidates: checkInOutCandidates, level: out var level); return(Ok(value: new CheckInOutResult { Text = text, AlertLevel = level, CheckInOutCandidates = checkInOutCandidates })); }