Esempio n. 1
0
        public async Task <IViewComponentResult> InvokeAsync(
            BadgesIndexOptions options)
        {
            if (options == null)
            {
                options = new BadgesIndexOptions();
            }

            return(View(await GetViewModel(options)));
        }
Esempio n. 2
0
        async Task <BadgesIndexViewModel> GetViewModel(BadgesIndexOptions options)
        {
            var entries = options.UserId > 0
                ? await _badgeEntriesStore.SelectByUserIdAsync(options.UserId)
                : await _badgeEntriesStore.SelectAsync();

            return(new BadgesIndexViewModel()
            {
                Badges = options.UserId > 0
                    ? entries?.OrderByDescending(b => b.Details.LastAwardedDate)
                    : entries?.OrderBy(b => b.Level)
            });
        }