Exemplo n.º 1
0
 public InviteeFilterSpecification(
     InviteeQueryParameters queryParameters)
     : base(
         x =>
         (!queryParameters.NameSearch.HasValue() ||
          x.LastName.IndexOf(
              queryParameters.NameSearch,
              StringComparison.CurrentCultureIgnoreCase)
          > 0 ||
          x.FirstName.IndexOf(
              queryParameters.NameSearch,
              StringComparison.CurrentCultureIgnoreCase)
          > 0) &&
         (!queryParameters.Email.HasValue() ||
          string.Equals(
              x.EmailAddress,
              queryParameters.Email,
              StringComparison.CurrentCultureIgnoreCase)) &&
         (!queryParameters.DietaryRestrictions.HasValue ||
          x.DietaryRestrictions.HasFlag(
              queryParameters.DietaryRestrictions)) &&
         (!queryParameters.FamilySide.HasValue ||
          x.FamilySide == queryParameters.FamilySide) &&
         (!queryParameters.MealChoice.HasValue ||
          x.MealChoiceId == (int)queryParameters.MealChoice) &&
         (!queryParameters.IsPlusOne.HasValue ||
          x.IsPlusOne == queryParameters.IsPlusOne))
 {
     AddInclude(x => x.Relationship);
     AddInclude(x => x.MealChoice);
 }
        /// <summary>
        /// Fetch many <see cref="Invitee"/>s via a set of <see cref="parameters"/>
        /// </summary>
        /// <param name="parameters">The search parameters</param>
        /// <returns>The fetched list of objects</returns>
        public IAsyncEnumerable <Invitee> Find(InviteeQueryParameters parameters)
        {
            var specification =
                new InviteeFilterSpecification(parameters);

            return(Repository.FindBySpecAsync(specification));
        }
        /// <summary>
        /// Fetch many <see cref="Invitee"/>s via a set of <see cref="parameters"/>
        /// and wrap the results in an <see cref="IPagedResult{TEntityModel}"/> suitable for UI pagination.
        /// </summary>
        /// <param name="parameters">The search parameters</param>
        /// <returns>The fetched list of objects in a paged result object</returns>
        public async Task <IPagedResult <Invitee> > FindPaged(
            InviteeQueryParameters parameters)
        {
            if (!parameters.Skip.HasValue || !parameters.Take.HasValue)
            {
                parameters.Skip = 0;
                parameters.Take = 10;
            }

            var results = Find(parameters);

            var list = await results.ToList();

            return(list.AsPaged(
                       parameters.Skip.Value,
                       parameters.Take.Value,
                       0));
        }
Exemplo n.º 4
0
 public async Task <IActionResult> Find(InviteeQueryParameters query)
 {
     return(Ok(await _inviteeService.FindPaged(query)));
 }