コード例 #1
0
    public async Task LogSearch(
        PeopleSearchParameters request,
        IImmutableList <Kid> people,
        string deviceGuid,
        CheckType checkType,
        bool filterLocations
        )
    {
        await using var db = CommonRepository.GetDatabase(serviceScopeFactory: _serviceScopeFactory);

        var securityCode = request.SecurityCode;
        var searchLog    = new SearchLog
        {
            SearchDate           = DateTime.UtcNow,
            SecurityCode         = securityCode.Length > 10 ? securityCode[..10] : securityCode,
コード例 #2
0
    public async Task <IImmutableList <KidsTown.Models.Kid> > GetPeople(
        PeopleSearchParameters peopleSearchParameters)
    {
        await using var db = CommonRepository.GetDatabase(serviceScopeFactory: _serviceScopeFactory);

        var attendances = await db.Attendances
                          .Include(navigationPropertyPath : a => a.Person)
                          .ThenInclude(navigationPropertyPath: p => p.Kid)
                          .Include(navigationPropertyPath: a => a.Location)
                          .Where(predicate: a => a.SecurityCode == peopleSearchParameters.SecurityCode &&
                                 (peopleSearchParameters.LocationGroups.Contains(a.Location.LocationGroupId) ||
                                  !peopleSearchParameters.UseFilterLocationGroups) &&
                                 a.InsertDate >= DateTime.Today &&
                                 a.Location.EventId == peopleSearchParameters.EventId)
                          .ToListAsync();

        return(attendances.Select(selector: MapKid).ToImmutableList());
    }
コード例 #3
0
 public async Task LogSearch(
     PeopleSearchParameters peopleSearchParameters,
     IImmutableList <Kid> people,
     string deviceGuid,
     CheckType checkType,
     bool filterLocations
     )
 {
     try
     {
         await _searchLoggingRepository.LogSearch(
             peopleSearchParameters : peopleSearchParameters,
             people : people,
             deviceGuid : deviceGuid,
             checkType : checkType,
             filterLocations : filterLocations);
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
     }
 }
コード例 #4
0
    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
        }));
    }
コード例 #5
0
ファイル: CheckInOutService.cs プロジェクト: nasiddi/KidsTown
 public async Task <IImmutableList <Kid> > SearchForPeople(PeopleSearchParameters searchParameters)
 {
     return(await _checkInOutRepository.GetPeople(peopleSearchParameters : searchParameters).ConfigureAwait(continueOnCapturedContext: false));
 }