Пример #1
0
        // Remove the updated thread with comments from session, so a fresh version can be fetched again.
        public void OnCommentsUpdatedCacheHandler(int threadId = 0, long commentId = 0)
        {
            if (_memoryCache.TryGetValue(Constant.Session.GlobalThreadsWithComments, out List <BBThread> fetchData))
            {
                if (fetchData.IsNullOrEmpty())
                {
                    return;
                }

                if (commentId > 0)
                {
                    if (fetchData.Any(x => x.ThreadComments.Any(c => c.CommentId == commentId)))
                    {
                        fetchData.RemoveAll(x => x.ThreadComments.Any(c => c.CommentId == commentId));
                        _memoryCache.Set(Constant.Session.GlobalThreadsWithComments, fetchData, TimeSpan.FromHours(24));
                    }
                }
                else if (fetchData.Any(x => x.ThreadId == threadId))
                {
                    BBThread desiredResult = fetchData.First(x => x.ThreadId == threadId);
                    fetchData.Remove(desiredResult);

                    _memoryCache.Set(Constant.Session.GlobalThreadsWithComments, fetchData, TimeSpan.FromHours(24));
                }
            }
        }
Пример #2
0
 public virtual bool _LoadAsync(String path, BBThread thread)
 {
     if (_Load(path))
     {
         thread.SetResult(this);
     }
 }
Пример #3
0
        public async Task <ResultsItem> CreateBBThread(BBThread thread)
        {
            if (!ModelState.IsValid)
            {
                return(ResultsItem.Error(ModelState.GetAllErrorsString()));
            }

            OnThreadUpdatedCacheHandler(thread.CategoryCode, thread.OfficialCoinId.GetValueOrDefault());
            return(await CommunityLogic.CreateBBThread(thread, CurrentUser));
        }
Пример #4
0
        public async Task <BBThread> GetThreadWithComments(int threadId)
        {
            if (_memoryCache.TryGetValue(Constant.Session.GlobalThreadsWithComments, out List <BBThread> fetchData))
            {
                if (!fetchData.IsNullOrEmpty() && fetchData.Any(x => x.ThreadId == threadId))
                {
                    return(fetchData.First(x => x.ThreadId == threadId));
                }
            }

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

            BBThread result = await CommunityLogic.GetThreadWithComments(threadId, CurrentUser);

            fetchData.Add(result);
            _memoryCache.Set(Constant.Session.GlobalThreadsWithComments, fetchData, TimeSpan.FromHours(24));

            return(result);
        }
Пример #5
0
 public static async Task <ResultsItem> CreateBBThread(BBThread thread, PegaUser user)
 {
     return(await CommunityRepository.CreateBBThread(thread, user));
 }
Пример #6
0
        public static async Task <BBThread> GetThreadWithComments(int threadId, PegaUser user)
        {
            BBThread thread = await CommunityRepository.GetBBThreadWithComments(threadId, user);

            return(thread);
        }
Пример #7
0
 public virtual bool _LoadAsync( String path,BBThread thread )
 {
     if( _Load( path ) ) thread.SetResult( this );
 }