예제 #1
0
        public async Task <ReadOnlyCollection <Candidate> > Search(string searchText, int maxResults, CancellationToken cancellationToken = default)
        {
            Candidate[] candidates;

            if (!string.IsNullOrEmpty(searchText))
            {
                if (int.TryParse(searchText, out var id))
                {
                    var candidate = await GetById(id, cancellationToken);

                    candidates = new[] { candidate };
                }
                else
                {
                    candidates = await _candidatesIncludableGetQuery
                                 .Where(x => x.Name.ToLowerInvariant().Contains(searchText.ToLowerInvariant()))
                                 .Take(maxResults)
                                 .ToArrayAsync(cancellationToken);
                }
            }
            else
            {
                candidates = await _candidatesIncludableGetQuery
                             .Take(maxResults)
                             .ToArrayAsync(cancellationToken);
            }

            return(Array.AsReadOnly(candidates));
        }
예제 #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="context"></param>
        /// <param name="cap"></param>
        /// <returns></returns>
        public static async Task <List <PatientJournal> > GetJournalsWithChildren(this AerendeContext context, int cap)
        {
            IIncludableQueryable <PatientJournal, Adress> patientJournals = context.GetChildrenInQuery();

            Task <List <PatientJournal> > patientJournlas_WithOrWithOutCap =
                cap == 0 ? patientJournals.ToListAsync() :
                patientJournals.Take(cap).ToListAsync();

            return(await patientJournlas_WithOrWithOutCap);
        }