コード例 #1
0
        public async Task <IActionResult> GetList(
            [Required][FromQuery] PeopleFilter filter, CancellationToken token)
        {
            var result = await queries.GetAsync(filter, token);

            return(GenerateResponse(result));
        }
コード例 #2
0
        public async Task <int> FilterDetailsCountAsync(PeopleFilter filter)
        {
            IQueryable <PersonEntity> entities = from p in Context.Set <PersonEntity>()
                                                 where !p.IsDeleted
                                                 select p;

            if (!string.IsNullOrEmpty(filter.FirstName))
            {
                entities = entities.Where(p => p.FirstName == filter.FirstName);
            }

            if (!string.IsNullOrEmpty(filter.LastName))
            {
                entities = entities.Where(p => p.LastName == filter.LastName);
            }

            if (!string.IsNullOrEmpty(filter.PersonalNumber))
            {
                entities = entities.Where(p => p.PersonalNumber == filter.PersonalNumber);
            }

            if (!string.IsNullOrEmpty(filter.PhoneNumber))
            {
                entities = entities.Where(p => p.PhoneNumber == filter.PhoneNumber);
            }

            if (filter.ID != null)
            {
                entities = entities.Where(p => p.ID == filter.ID);
            }

            return(await entities.CountAsync());
        }
コード例 #3
0
ファイル: PersonController.cs プロジェクト: mbostel/AgeRanger
        private IPeopleFilter BuildFilterFromUri()
        {
            var filter = new PeopleFilter();

            var query      = Request.RequestUri.Query;
            var parmValues = System.Web.HttpUtility.ParseQueryString(query);

            filter.FirstName = parmValues.Get("FirstName");
            filter.LastName  = parmValues.Get("LastName");

            int n;

            string Value = parmValues.Get("MinAge");

            if (int.TryParse(Value, out n))
            {
                filter.MinAge = n;
            }

            Value = parmValues.Get("MaxAge");

            if (int.TryParse(Value, out n))
            {
                filter.MaxAge = n;
            }


            return(filter);
        }
コード例 #4
0
ファイル: GameContext.cs プロジェクト: shsanek/IAmTheLaw
 public People SearchPeopl(PeopleFilter filter)
 {
     foreach (var people in this._peopls)
     {
         if (filter(people))
         {
             return(people);
         }
     }
     return(null);
 }
コード例 #5
0
ファイル: PeopleGrid.xaml.cs プロジェクト: TheSklyar/MMSDLab2
 public PeopleGrid(ConnectionSettings connectionSettings, bool fromOtherView = false)
 {
     this.fromOtherView  = fromOtherView;
     _connectionSettings = Guard.GetNotNull(connectionSettings, "connectionSettings");
     InitializeComponent();
     Filter      = new PeopleFilter(connectionSettings);
     DataContext = Filter;
     CountPages();
     InitTable();
     SetFiltersToNull();
 }
コード例 #6
0
ファイル: GameContext.cs プロジェクト: shsanek/IAmTheLaw
        public List <People> FilterPeopls(PeopleFilter filter)
        {
            var result = new List <People>();

            foreach (var people in this._peopls)
            {
                if (filter(people))
                {
                    result.Add(people);
                }
            }
            return(result);
        }
コード例 #7
0
ファイル: PersonQueries.cs プロジェクト: morbalint/architect
        public virtual async Task <IListResponse <PersonAggregate> > GetAsync(
            PeopleFilter filter, CancellationToken token = default)
        {
            filter.ArgumentNullCheck(nameof(filter));

            var query = context.Set <PersonAggregate>()
                        .StringFilter(filter.Filter, x => x.Name, x => x.Address);

            var totalCount = await query.CountAsync(token);

            var items = await query.Paginate(filter).ToListAsync(token);

            return(new ListResponse <PersonAggregate>(items, totalCount,
                                                      filter.Page ?? 1, totalCount.CountPages(filter.PageSize)));
        }
コード例 #8
0
        public async Task <ICollection <Person> > FilterInDetailsAsync(PeopleFilter filter, int skip, int take, string sortingColumn)
        {
            IQueryable <PersonEntity> entities = from p in Context.Set <PersonEntity>()
                                                 where !p.IsDeleted
                                                 orderby sortingColumn descending
                                                 select p;

            if (!string.IsNullOrEmpty(filter.FirstName))
            {
                entities = entities.Where(p => p.FirstName == filter.FirstName);
            }

            if (!string.IsNullOrEmpty(filter.LastName))
            {
                entities = entities.Where(p => p.LastName == filter.LastName);
            }

            if (!string.IsNullOrEmpty(filter.PersonalNumber))
            {
                entities = entities.Where(p => p.PersonalNumber == filter.PersonalNumber);
            }

            if (!string.IsNullOrEmpty(filter.PhoneNumber))
            {
                entities = entities.Where(p => p.PhoneNumber == filter.PhoneNumber);
            }

            if (filter.ID != null)
            {
                entities = entities.Where(p => p.ID == filter.ID);
            }

            var result = await entities
                         .Skip(skip)
                         .Take(take)
                         .ToListAsync();

            return(mapper.Map <List <Person> >(result));
        }
コード例 #9
0
        public async Task <FilterResponse <IEnumerable <PeopleListItem> > > FilterInDetails(FilterModel <FilterPeopleQuery> f)
        {
            var personFilter = new PeopleFilter
            {
                BirthDate       = f.Filter.BirthDate,
                CityID          = f.Filter.CityID,
                FirstName       = f.Filter.FirstName,
                Gender          = f.Filter.Gender,
                ID              = f.Filter.ID,
                LastName        = f.Filter.LastName,
                PersonalNumber  = f.Filter.PersonalNumber,
                PhoneNumber     = f.Filter.PhoneNumber,
                PhoneNumberType = f.Filter.PhoneNumberType
            };

            var searchResult = await _peopleDomainService.DeepSearch(personFilter,
                                                                     f.PageRequest.Index,
                                                                     f.PageRequest.ShowPerPage,
                                                                     f.PageRequest.SortingColumn);

            var items = searchResult.Item1.Select(i => new PeopleListItem
            {
                ID             = i.ID,
                BirthDate      = i.BirthDate,
                City           = i.City,
                CityID         = i.CityID,
                FirstName      = i.FirstName,
                Gender         = (int)i.Gender,
                ImageUrl       = i.ImageUrl,
                LastName       = i.LastName,
                PersonalNumber = i.PersonalNumber,
                PhoneNumber    = i.PhoneNumber.Number.Value,
            });

            return(new FilterResponse <IEnumerable <PeopleListItem> >(items, searchResult.Item2));
        }
コード例 #10
0
        public IEnumerable <Person> GetAll(PageRequest pageRequest, out PageResponse pageResponse, PeopleFilter peopleFilter = null)
        {
            var persons = context.People
                          .Include(x => x.City)
                          .Include(x => x.Phones)
                          .Include(x => x.RelatedPeople)
                          .ThenInclude(x => x.RelatedPerson)
                          .ThenInclude(x => x.Phones)
                          .ApplyFilterParameters(peopleFilter)
                          .TakePage(pageRequest, out pageResponse)
                          .ToList();

            return(persons);
        }
コード例 #11
0
        public static IQueryable <Person> ApplyFilterParameters(this IQueryable <Person> source, PeopleFilter peopleFilter)
        {
            if (peopleFilter == null)
            {
                return(source);
            }

            if (!string.IsNullOrEmpty(peopleFilter.FirstName?.Trim()))
            {
                source = source.Where(x => x.FirstName.StartsWith(peopleFilter.FirstName));
            }

            if (!string.IsNullOrEmpty(peopleFilter.LastName?.Trim()))
            {
                source = source.Where(x => x.LastName.StartsWith(peopleFilter.LastName));
            }

            if (!string.IsNullOrEmpty(peopleFilter.Pn?.Trim()))
            {
                source = source.Where(x => x.Pn.StartsWith(peopleFilter.Pn));
            }

            if (peopleFilter.BirthDate.HasValue)
            {
                source = source.Where(x => x.BirthDate.Date == peopleFilter.BirthDate.Value.Date);
            }

            if (peopleFilter.CityId > 0)
            {
                source = source.Where(x => x.CityId == peopleFilter.CityId);
            }

            if (peopleFilter.HasPhoto.HasValue)
            {
                if (peopleFilter.HasPhoto.Value)
                {
                    source = source.Where(x => (x.PhotoPath == null || x.PhotoPath == ""));
                }
                else
                {
                    source = source.Where(x => !(x.PhotoPath == null || x.PhotoPath == ""));
                }
            }

            if (!string.IsNullOrEmpty(peopleFilter.City?.Trim()))
            {
                source = source
                         .Where(x => x.City.Name.StartsWith(peopleFilter.City));
            }

            if (!string.IsNullOrEmpty(peopleFilter.RelatedPersonFirstName?.Trim()))
            {
                source = source
                         .Where(r => r.RelatedPeople.Any(x => x.RelatedPerson.FirstName.StartsWith(peopleFilter.RelatedPersonFirstName)));
            }

            if (!string.IsNullOrEmpty(peopleFilter.RelatedPersonLastName?.Trim()))
            {
                source = source
                         .Where(r => r.RelatedPeople.Any(x => x.RelatedPerson.LastName.StartsWith(peopleFilter.RelatedPersonLastName)));
            }

            if (!string.IsNullOrEmpty(peopleFilter.RelatedPersonPn?.Trim()))
            {
                source = source
                         .Where(r => r.RelatedPeople.Any(x => x.RelatedPerson.Pn.StartsWith(peopleFilter.RelatedPersonPn)));
            }

            return(source);
        }