Пример #1
0
        private PartialViewResult Search(MatchesSearchViewModel search, int page)
        {
            var allMatchesCount = this.matchesService.All().Count();
            var totalPages      = (int)Math.Ceiling(allMatchesCount / (decimal)Constants.MatchesPerPage);

            var matches = this.matchesService.Search(search.SearchWord, search.SortBy, search.SortType, page)
                          .Select(m => new
            {
                XmlId     = m.XmlId,
                Name      = m.Name,
                StartDate = m.StartDate,
                MatchType = m.MatchType,
                IsDeleted = m.IsDeleted
            })
                          .Select(Mapper.DynamicMap <MatchViewModel>)
                          .ToList();

            var matchesListViewModel = new MatchesSearchResultViewModel()
            {
                Matches     = matches,
                CurrentPage = page,
                TotalPages  = totalPages
            };

            return(this.PartialView("_MatchesPartial", matchesListViewModel));
        }
Пример #2
0
        public PartialViewResult SearchMatches(MatchesSearchViewModel searchModel, int?page)
        {
            Guard.WhenArgument(searchModel, nameof(searchModel)).IsNull().Throw();

            int actualPage = page ?? Constants.MatchesStartPage;

            Guard.WhenArgument(actualPage, nameof(actualPage)).IsLessThan(Constants.MatchesStartPage).Throw();

            return(this.Search(searchModel, actualPage));
        }