Пример #1
0
        public async Task <PartialViewResult> GetAllConversationThreads(int take = 50)
        {
            ConversationsVM vm = new ConversationsVM
            {
                Threads = await CommunityLogic.GetMessageThreads(take, new List <Types.ConvThreadCategory> {
                    Types.ConvThreadCategory.MainDashboard,
                    Types.ConvThreadCategory.OfficialCoins, Types.ConvThreadCategory.FeatureRequests
                }, CurrentUser),
                CurrentUser       = CurrentUser,
                HideCreateNewPost = true
            };

            List <OfficialCoin> officialCoins = CryptoLogic.GetAllOfficialCoins();

            foreach (var x in vm.Threads.Where(x => x.OfficialCoinId > 0))
            {
                OfficialCoin officialCoin = officialCoins.FirstOrDefault(o => o.OfficialCoinId == x.OfficialCoinId);
                if (officialCoin == null)
                {
                    continue;
                }

                x.OfficialCoin = officialCoin;
                x.ShowOfficialCoinNameOnThread = true;
            }

            return(PartialView("_Conversations", vm));
        }
Пример #2
0
        public async Task <List <BBThread> > GetThreadsByCategory(int take, Types.ConvThreadCategory category, int officialCoinId = 0)
        {
            if (_memoryCache.TryGetValue(Constant.Session.GlobalThreadsByCategory, out List <ConversationFetchData> fetchData))
            {
                if (!fetchData.IsNullOrEmpty() && fetchData.Any(x => x.Take == take && x.Category == category && x.OfficialCoinId == officialCoinId))
                {
                    // This results already exist.
                    ConversationFetchData desiredResult = fetchData.First(x => x.Take == take && x.Category == category && x.OfficialCoinId == officialCoinId);
                    return(desiredResult.Results);
                }
            }

            // Results does not exist, or fetchData itself is non-existant.
            if (fetchData.IsNullOrEmpty())
            {
                fetchData = new List <ConversationFetchData>();
            }

            List <BBThread> results = await CommunityLogic.GetMessageThreads(50, Types.ConvThreadCategory.MainDashboard, CurrentUser, officialCoinId : officialCoinId);

            fetchData.Add(new ConversationFetchData
            {
                Take           = take,
                Category       = category,
                OfficialCoinId = officialCoinId,
                Results        = results
            });
            _memoryCache.Set(Constant.Session.GlobalThreadsByCategory, fetchData, TimeSpan.FromHours(24));

            return(results);
        }