Esempio n. 1
0
        public Task <People[]> HandleAsync(string[] firstName, string[] surname, int?minAge, int?maxAge, CancellationToken cancellationToken)
        {
            return(Task.FromResult(peopleService.AllPeople().Where(w =>
            {
                if (firstName.Length != 0 && !firstName.Contains(w.FirstName))
                {
                    return false;
                }
                if (surname.Length != 0 && !surname.Contains(w.Surname))
                {
                    return false;
                }

                if (minAge.HasValue && w.Age < minAge.Value)
                {
                    return false;
                }

                if (maxAge.HasValue && w.Age > maxAge.Value)
                {
                    return false;
                }

                return true;
            })
                                   .ToArray()));
        }
Esempio n. 2
0
        public Task <IEndpointResult> HandleAsync(int id, CancellationToken cancellationToken)
        {
            var person = peopleService.AllPeople().SingleOrDefault(p => p.Id == id);

            if (person is null)
            {
                return(Task.FromResult(EndpointResult.NotFound()));
            }
            return(Task.FromResult(EndpointResult.Ok(person)));
        }