示例#1
0
        public ParticipantsReceptionViewModel BuildParticipantSearch(IDisplayPagination pagination, string searchWords)
        {
            if (searchWords.IsEmptyString())
            {
                return(new ParticipantsReceptionViewModel());
            }

            var conventionId = Actor.ManagedConvention.ConventionId;
            var query        = Session
                               .Query <Participants_BySearchQuery.Result, Participants_BySearchQuery>()
                               .Include(x => x.ParticipantId)
                               .Include(x => x.ConventionId)
                               .Include(x => x.EventIds)
                               .Statistics(out var stats)
                               .Search(x => x.SearchText, searchWords)
                               .Where(x => x.IsLongTerm || x.ConventionId == conventionId)
                               .OrderBy(x => x.FullName)
                               .Skip(pagination.SkipCount)
                               .Take(pagination.ResultsPerPage)
                               .As <ConventionEngagement>()
                               .ToList();

            var wrapperFactory = new Factories.WrapperFactory(Session);
            var viewModel      = new ParticipantsReceptionViewModel
            {
                Pagination = DisplayPagination.BuildForView(
                    stats.TotalResults,
                    pagination.SkipCount,
                    pagination.ResultsPerPage),
                Participants = wrapperFactory.Wrap(query)
            };

            return(viewModel);
        }
        public ConventionManagementViewModel BuildConventionList(IDisplayPagination pagination)
        {
            var result      = new ConventionManagementViewModel();
            var conventions = Session
                              .Query <Convention>()
                              .Include(x => x.DayIds)
                              .Include(x => x.HallIds)
                              .Include(x => x.TicketIds)
                              .Statistics(out var stats)
                              .OrderByDescending(x => x.CreateTimeStamp)
                              .Skip(pagination.SkipCount)
                              .Take(pagination.ResultsPerPage)
                              .ToList();

            var wrapperFactory = new WrapperFactory(Session);

            result.Conventions = wrapperFactory.Wrap(conventions);
            result.Pagination  = DisplayPagination.BuildForView(stats.TotalResults, pagination.SkipCount, pagination.ResultsPerPage);
            return(result);
        }
        public ParticipantsManagementViewModel BuildSearchIndex(IDisplayPagination pagination, bool allowHistory = false, string searchWords = "")
        {
            if (searchWords.IsEmptyString())
            {
                return(new ParticipantsManagementViewModel());
            }

            var query = Session.Query <Participants_BySearchQuery.Result, Participants_BySearchQuery>()
                        .Include(x => x.ParticipantId)
                        .Include(x => x.ConventionId)
                        .Statistics(out var stats)
                        .Search(x => x.SearchText, searchWords).AsQueryable();

            if (allowHistory == false)
            {
                query = query.Where(x => x.ConventionId == Actor.ManagedConvention.ConventionId);
            }

            var results = query
                          .OrderBy(x => x.FullName)
                          .Skip(pagination.SkipCount)
                          .Take(pagination.ResultsPerPage)
                          .As <ConventionEngagement>()
                          .ToList();

            var wrapperFactory = new WrapperFactory(Session);
            var viewModel      = new ParticipantsManagementViewModel
            {
                Pagination = DisplayPagination.BuildForView(
                    stats.TotalResults,
                    pagination.SkipCount,
                    pagination.ResultsPerPage),
                Engagements = wrapperFactory.Wrap(results, false),
                filters     = new ParticipantsManagementViewModel.Filters()
            };

            return(viewModel);
        }