/// <summary>
        /// Fetch many <see cref="Invitation"/>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 <Invitation> Find(
            InvitationQueryParameters parameters)
        {
            var specification =
                new InvitationFilterSpecification(parameters);

            return(Repository.FindBySpecAsync(specification));
        }
        /// <summary>
        /// Fetch many <see cref="Invitation"/>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 <Invitation> > FindPaged(
            InvitationQueryParameters 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));
        }
Пример #3
0
        InvitationFilterSpecification(
            InvitationQueryParameters queryParameters)
            : base(
                x => (!queryParameters.InviteeNameSearch.HasValue() ||
                      x.EnvelopeAddressee.IndexOf(
                          queryParameters.InviteeNameSearch,
                          StringComparison.CurrentCultureIgnoreCase)
                      > 0 &&
                      (!queryParameters.InvitationType.HasValue ||
                       x.InvitationType == queryParameters.InvitationType) &&
                      (!queryParameters.InvitationCode.HasValue() ||
                       x.InvitationCode == queryParameters.InvitationCode) &&
                      (!queryParameters.IsMissingPlusOne.HasValue ||
                       x.IsMissingPlusOne
                       == queryParameters.IsMissingPlusOne) &&
                      (!queryParameters.IsInvitationEnvelopePrinted.HasValue ||
                       x.IsInvitationEnvelopePrinted
                       == queryParameters.IsInvitationEnvelopePrinted) &&
                      (!queryParameters.IsInvitationSent.HasValue ||
                       x.IsInvitationSent
                       == queryParameters.IsInvitationSent) &&
                      (!queryParameters.InviteeHasDietaryRestriction.HasValue ||
                       x.InviteeHasDietaryRestriction
                       == queryParameters.InviteeHasDietaryRestriction)
                      )
                )
        {
            AddInclude(x => x.Invitees);
            AddInclude(x => x.Address);

            if (queryParameters.Skip.HasValue && queryParameters.Take.HasValue)
            {
                ApplyPaging(
                    queryParameters.Skip.Value,
                    queryParameters.Take.Value);
            }
        }
Пример #4
0
 public async Task <IActionResult> Find(InvitationQueryParameters query)
 {
     return(Ok(await _invitationService.FindPaged(query)));
 }