Ejemplo n.º 1
0
 /// <summary>
 /// 获取一条动态
 /// </summary>
 /// <param name="authorIdCode">作者识别码</param>
 /// <param name="sidForAuthor">动态在作者名下的序号</param>
 /// <param name="dbContext"><see cref="KeylolDbContext"/></param>
 /// <param name="cachedData"><see cref="CachedDataProvider"/></param>
 /// <param name="userManager"><see cref="KeylolUserManager"/></param>
 /// <returns><see cref="ActivityPage"/></returns>
 public static async Task <ActivityPage> Get(string authorIdCode, int sidForAuthor,
                                             [Injected] KeylolDbContext dbContext, [Injected] CachedDataProvider cachedData,
                                             [Injected] KeylolUserManager userManager)
 {
     return(await CreateAsync(authorIdCode, sidForAuthor, StateTreeHelper.GetCurrentUserId(),
                              StateTreeHelper.GetCurrentUser().IsInRole(KeylolRoles.Operator), dbContext, cachedData, userManager));
 }
Ejemplo n.º 2
0
 /// <summary>
 /// 获取用户个人层级状态树
 /// </summary>
 /// <param name="entrance">要获取的页面</param>
 /// <param name="userIdCode">用户识别码</param>
 /// <param name="dbContext"><see cref="KeylolDbContext"/></param>
 /// <param name="cachedData"><see cref="CachedDataProvider"/></param>
 /// <param name="userManager"><see cref="KeylolUserManager"/></param>
 /// <returns><see cref="UserLevel"/></returns>
 public static async Task <UserLevel> Get(string entrance, string userIdCode,
                                          [Injected] KeylolDbContext dbContext, [Injected] CachedDataProvider cachedData,
                                          [Injected] KeylolUserManager userManager)
 {
     return(await CreateAsync(StateTreeHelper.GetCurrentUserId(), userIdCode,
                              entrance.ToEnum <EntrancePage>(), dbContext, cachedData, userManager));
 }
Ejemplo n.º 3
0
        /// <summary>
        /// 获取时间轴卡片列表
        /// </summary>
        /// <param name="before">起始位置</param>
        /// <param name="take">获取数量</param>
        /// <param name="dbContext"><see cref="KeylolDbContext"/></param>
        /// <param name="cachedData"><see cref="CachedDataProvider"/></param>
        /// <returns><see cref="TimelineCardList"/></returns>
        public static async Task <TimelineCardList> GetCards(int before, int take, [Injected] KeylolDbContext dbContext,
                                                             [Injected] CachedDataProvider cachedData)
        {
            var currentUserId = StateTreeHelper.GetCurrentUserId();

            return(await TimelineCardList.CreateAsync(SubscriptionStream.Name(currentUserId), currentUserId,
                                                      take, false, dbContext, cachedData, before));
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 获取据点扉页
        /// </summary>
        /// <param name="pointIdCode">据点识别码</param>
        /// <param name="dbContext"><see cref="KeylolDbContext"/></param>
        /// <param name="cachedData"><see cref="CachedDataProvider"/></param>
        /// <returns><see cref="FrontpagePage"/></returns>
        public static async Task <FrontpagePage> Get(string pointIdCode, [Injected] KeylolDbContext dbContext,
                                                     [Injected] CachedDataProvider cachedData)
        {
            var point = await dbContext.Points.Where(p => p.IdCode == pointIdCode).SingleOrDefaultAsync();

            if (point == null)
            {
                return(new FrontpagePage());
            }
            return(await CreateAsync(point, StateTreeHelper.GetCurrentUserId(), dbContext, cachedData));
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 获取指定用户的档案页
        /// </summary>
        /// <param name="userIdCode">用户识别码</param>
        /// <param name="dbContext"><see cref="KeylolDbContext"/></param>
        /// <param name="cachedData"><see cref="CachedDataProvider"/></param>
        /// <param name="userManager"><see cref="KeylolUserManager"/></param>
        /// <returns><see cref="DossierPage"/></returns>
        public static async Task <DossierPage> Get(string userIdCode, [Injected] KeylolDbContext dbContext,
                                                   [Injected] CachedDataProvider cachedData, [Injected] KeylolUserManager userManager)
        {
            var user = await userManager.FindByIdCodeAsync(userIdCode);

            if (user == null)
            {
                return(new DossierPage());
            }
            return(await CreateAsync(user, StateTreeHelper.GetCurrentUserId(), dbContext, cachedData, userManager));
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 获取简评列表
        /// </summary>
        /// <param name="pointId">据点 ID</param>
        /// <param name="page">分页页码</param>
        /// <param name="dbContext"><see cref="KeylolDbContext"/></param>
        /// <param name="cachedData"><see cref="CachedDataProvider"/></param>
        /// <returns><see cref="BriefReviewList"/></returns>
        public static async Task <BriefReviewList> Get(string pointId, int page, [Injected] KeylolDbContext dbContext,
                                                       [Injected] CachedDataProvider cachedData)
        {
            var point = await dbContext.Points.FindAsync(pointId);

            if (point == null)
            {
                return(new BriefReviewList(0));
            }
            return
                ((await CreateAsync(point, StateTreeHelper.GetCurrentUserId(), page, false, dbContext, cachedData)).Item1);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 获取指定文章的评论列表
        /// </summary>
        /// <param name="articleId">文章 ID</param>
        /// <param name="page">分页页码</param>
        /// <param name="dbContext"><see cref="KeylolDbContext"/></param>
        /// <param name="cachedData"><see cref="CachedDataProvider"/></param>
        /// <returns><see cref="ArticleCommentList"/></returns>
        public static async Task <ArticleCommentList> Get(string articleId, int page,
                                                          [Injected] KeylolDbContext dbContext, [Injected] CachedDataProvider cachedData)
        {
            var article = await dbContext.Articles
                          .Include(a => a.Author)
                          .Include(a => a.TargetPoint)
                          .Where(a => a.Id == articleId)
                          .SingleOrDefaultAsync();

            if (article == null)
            {
                return(new ArticleCommentList(0));
            }

            return((await CreateAsync(article, page, StateTreeHelper.GetCurrentUserId(),
                                      StateTreeHelper.GetCurrentUser().IsInRole(KeylolRoles.Operator), false, dbContext, cachedData)).Item1);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// 通过关键字查询据点列表
        /// </summary>
        /// <param name="keyword">关键字</param>
        /// <param name="headerImage">返回结果是否包含页眉图片</param>
        /// <param name="playedTime">返回结果是否包含在档时间</param>
        /// <param name="typeWhitelist">据点类型白名单,逗号分隔</param>
        /// <param name="dbContext"><see cref="KeylolDbContext"/></param>
        /// <returns><see cref="PointQueryResultList"/></returns>
        public static async Task <PointQueryResultList> Get(string keyword, [Injected] KeylolDbContext dbContext,
                                                            bool headerImage = false, bool playedTime = false, string typeWhitelist = null)
        {
            List <PointType> types = null;

            if (!string.IsNullOrWhiteSpace(typeWhitelist))
            {
                types = typeWhitelist.Split(',')
                        .Select(s => s.Trim()
                                .ToCase(NameConventionCase.CamelCase, NameConventionCase.PascalCase)
                                .ToEnum <PointType>())
                        .ToList();
            }
            var currentUserId = StateTreeHelper.GetCurrentUserId();

            return(await CreateAsync(currentUserId, keyword, headerImage, playedTime, types, dbContext));
        }
Ejemplo n.º 9
0
 /// <summary>
 /// 获取入坑用户列表
 /// </summary>
 /// <param name="steamAppId">Steam App ID</param>
 /// <param name="page">分页页码</param>
 /// <param name="dbContext"><see cref="KeylolDbContext"/></param>
 /// <param name="cachedData"><see cref="CachedDataProvider"/></param>
 /// <returns><see cref="AddictedUserList"/></returns>
 public static async Task <AddictedUserList> Get(int steamAppId, int page, [Injected] KeylolDbContext dbContext,
                                                 [Injected] CachedDataProvider cachedData)
 {
     return(await CreateAsync(StateTreeHelper.GetCurrentUserId(), steamAppId, page,
                              dbContext, cachedData));
 }
Ejemplo n.º 10
0
 /// <summary>
 /// 获取精选谈论
 /// </summary>
 /// <param name="page">分页页码</param>
 /// <param name="dbContext"><see cref="KeylolDbContext"/></param>
 /// <param name="cachedData"><see cref="CachedDataProvider"/></param>
 /// <returns><see cref="SpotlightArticleList"/></returns>
 public static async Task <SpotlightArticleList> GetSpotlightStories(int page,
                                                                     [Injected] KeylolDbContext dbContext, [Injected] CachedDataProvider cachedData)
 {
     return(await SpotlightArticleList.CreateAsync(StateTreeHelper.GetCurrentUserId(), page, 12,
                                                   SpotlightArticleStream.ArticleCategory.Story, dbContext, cachedData));
 }
Ejemplo n.º 11
0
 /// <summary>
 /// 获取指定用户订阅的据点列表
 /// </summary>
 /// <param name="userId">用户 ID</param>
 /// <param name="page">分页页码</param>
 /// <param name="dbContext"><see cref="KeylolDbContext"/></param>
 /// <param name="cachedData"><see cref="CachedDataProvider"/></param>
 /// <returns><see cref="SubscribedPointList"/></returns>
 public static async Task <SubscribedPointList> Get(string userId, int page, [Injected] KeylolDbContext dbContext,
                                                    [Injected] CachedDataProvider cachedData)
 {
     return((await CreateAsync(StateTreeHelper.GetCurrentUserId(), userId, page, 30, false, dbContext,
                               cachedData)).Item1);
 }
Ejemplo n.º 12
0
 /// <summary>
 /// 获取文券明细页
 /// </summary>
 /// <param name="dbContext"><see cref="KeylolDbContext"/></param>
 /// <param name="userManager"><see cref="KeylolUserManager"/></param>
 /// <returns><see cref="DetailPage"/></returns>
 public static async Task <DetailPage> Get([Injected] KeylolDbContext dbContext,
                                           [Injected] KeylolUserManager userManager)
 {
     return(await CreateAsync(StateTreeHelper.GetCurrentUserId(), dbContext, userManager));
 }
Ejemplo n.º 13
0
 /// <summary>
 /// 获取近畿据点列表
 /// </summary>
 /// <param name="pointId">据点 ID</param>
 /// <param name="page">分页页码</param>
 /// <param name="dbContext"><see cref="KeylolDbContext"/></param>
 /// <param name="cachedData"><see cref="CachedDataProvider"/></param>
 /// <returns><see cref="SimilarPointList"/></returns>
 public static async Task <SimilarPointList> Get(string pointId, int page, [Injected] KeylolDbContext dbContext,
                                                 [Injected] CachedDataProvider cachedData)
 {
     return(await CreateAsync(pointId, StateTreeHelper.GetCurrentUserId(), page,
                              dbContext, cachedData));
 }
Ejemplo n.º 14
0
 /// <summary>
 /// 获取文券商店页面
 /// </summary>
 /// <param name="dbContext"><see cref="KeylolDbContext"/></param>
 /// <param name="cachedData"><see cref="CachedDataProvider"/></param>
 /// <param name="userManager"></param>
 /// <param name="coupon"></param>
 /// <returns><see cref="StorePage"/></returns>
 public static async Task <StorePage> Get([Injected] KeylolDbContext dbContext,
                                          [Injected] CachedDataProvider cachedData, [Injected] KeylolUserManager userManager, [Injected] CouponProvider coupon)
 {
     return(await CreateAsync(StateTreeHelper.GetCurrentUserId(), dbContext, cachedData, userManager, coupon));
 }
Ejemplo n.º 15
0
 /// <summary>
 /// 获取哨所据点列表
 /// </summary>
 /// <param name="page">分页页码</param>
 /// <param name="dbContext"><see cref="KeylolDbContext"/></param>
 /// <param name="cachedData"><see cref="CachedDataProvider"/></param>
 /// <returns><see cref="OutpostPointList"/></returns>
 public static async Task <OutpostPointList> Get(int page, [Injected] KeylolDbContext dbContext,
                                                 [Injected] CachedDataProvider cachedData)
 {
     return(await CreateAsync(StateTreeHelper.GetCurrentUserId(), page, 12, dbContext, cachedData));
 }
Ejemplo n.º 16
0
 /// <summary>
 /// 获取“入口 - 轨道”页面状态分支
 /// </summary>
 /// <param name="dbContext"><see cref="KeylolDbContext"/></param>
 /// <param name="cachedData"><see cref="CachedDataProvider"/></param>
 /// <returns><see cref="TimelinePage"/></returns>
 public static async Task <TimelinePage> Get([Injected] KeylolDbContext dbContext,
                                             [Injected] CachedDataProvider cachedData)
 {
     return(await CreateAsync(StateTreeHelper.GetCurrentUserId(), dbContext, cachedData));
 }
Ejemplo n.º 17
0
 /// <summary>
 /// 获取指定用户的文选
 /// </summary>
 /// <param name="userId">用户 ID</param>
 /// <param name="page">分页页码</param>
 /// <param name="dbContext"><see cref="KeylolDbContext"/></param>
 /// <param name="cachedData"><see cref="CachedDataProvider"/></param>
 /// <returns></returns>
 public static async Task <SelectedArticleList> Get(string userId, int page, [Injected] KeylolDbContext dbContext,
                                                    [Injected] CachedDataProvider cachedData)
 {
     return((await CreateAsync(userId, page, 12, false, StateTreeHelper.GetCurrentUserId(), dbContext,
                               cachedData)).Item1);
 }
Ejemplo n.º 18
0
        /// <summary>
        /// 获取新的完整状态树
        /// </summary>
        /// <param name="state">当前 UI 状态</param>
        /// <param name="userManager"><see cref="KeylolUserManager"/></param>
        /// <param name="dbContext"><see cref="KeylolDbContext"/></param>
        /// <param name="coupon"><see cref="CouponProvider"/></param>
        /// <param name="cachedData"><see cref="CachedDataProvider"/></param>
        /// <param name="pointIdCode">据点识别码</param>
        /// <param name="authorIdCode">作者识别码</param>
        /// <param name="userIdCode">用户识别码</param>
        /// <param name="sidForAuthor">文章在作者名下的序号</param>
        /// <param name="keyword">搜索关键字</param>
        /// <returns>完整状态树</returns>
        public static async Task <Root> Locate(string state, [Injected] KeylolUserManager userManager,
                                               [Injected] KeylolDbContext dbContext, [Injected] CouponProvider coupon,
                                               [Injected] CachedDataProvider cachedData, string pointIdCode = null, string authorIdCode = null,
                                               string userIdCode = null, int sidForAuthor = 0, string keyword = null)
        {
            var root          = new Root();
            var currentUserId = StateTreeHelper.GetCurrentUserId();
            var isOperator    = StateTreeHelper.GetCurrentUser().IsInRole(KeylolRoles.Operator);

            if (await StateTreeHelper.CanAccessAsync <Root>(nameof(CurrentUser)))
            {
                var user = await userManager.FindByIdAsync(currentUserId);

                root.CurrentUser = await CurrentUser.CreateAsync(user, userManager, dbContext, coupon, cachedData);
            }

            switch (state)
            {
            case "entrance":
                root.Entrance = await EntranceLevel.CreateAsync(currentUserId,
                                                                States.Entrance.EntrancePage.Auto, dbContext, cachedData);

                break;

            case "entrance.discovery":
                root.Entrance = await EntranceLevel.CreateAsync(currentUserId,
                                                                States.Entrance.EntrancePage.Discovery, dbContext, cachedData);

                break;

            case "entrance.points":
                root.Entrance = await EntranceLevel.CreateAsync(currentUserId,
                                                                States.Entrance.EntrancePage.Points, dbContext, cachedData);

                break;

            case "entrance.timeline":
                root.Entrance = await EntranceLevel.CreateAsync(currentUserId,
                                                                States.Entrance.EntrancePage.Timeline, dbContext, cachedData);

                break;

            case "aggregation.point":
                root.Aggregation = new AggregationLevel
                {
                    Point = await PointLevel.CreateAsync(currentUserId, pointIdCode,
                                                         States.Aggregation.Point.EntrancePage.Auto, dbContext, cachedData)
                };
                break;

            case "aggregation.point.frontpage":
                root.Aggregation = new AggregationLevel
                {
                    Point = await PointLevel.CreateAsync(currentUserId, pointIdCode,
                                                         States.Aggregation.Point.EntrancePage.Frontpage, dbContext, cachedData)
                };
                break;

            case "aggregation.point.intel":
                root.Aggregation = new AggregationLevel
                {
                    Point = await PointLevel.CreateAsync(currentUserId, pointIdCode,
                                                         States.Aggregation.Point.EntrancePage.Intel, dbContext, cachedData)
                };
                break;

            case "aggregation.point.product":
                root.Aggregation = new AggregationLevel
                {
                    Point = await PointLevel.CreateAsync(currentUserId, pointIdCode,
                                                         States.Aggregation.Point.EntrancePage.Product, dbContext, cachedData)
                };
                break;

            case "aggregation.point.timeline":
                root.Aggregation = new AggregationLevel
                {
                    Point = await PointLevel.CreateAsync(currentUserId, pointIdCode,
                                                         States.Aggregation.Point.EntrancePage.Timeline, dbContext, cachedData)
                };
                break;

            case "aggregation.point.edit.info":
                root.Aggregation = new AggregationLevel
                {
                    Point = await PointLevel.CreateAsync(currentUserId, pointIdCode,
                                                         States.Aggregation.Point.EntrancePage.EditInfo, dbContext, cachedData)
                };
                break;

            case "aggregation.point.edit.style":
                root.Aggregation = new AggregationLevel
                {
                    Point = await PointLevel.CreateAsync(currentUserId, pointIdCode,
                                                         States.Aggregation.Point.EntrancePage.EditStyle, dbContext, cachedData)
                };
                break;

            case "aggregation.user":
                root.Aggregation = new AggregationLevel
                {
                    User = await UserLevel.CreateAsync(currentUserId, userIdCode, EntrancePage.Auto,
                                                       dbContext, cachedData, userManager)
                };
                break;

            case "aggregation.user.dossier":
                root.Aggregation = new AggregationLevel
                {
                    User = await UserLevel.CreateAsync(currentUserId, userIdCode, EntrancePage.Dossier,
                                                       dbContext, cachedData, userManager)
                };
                break;

            case "aggregation.user.people":
                root.Aggregation = new AggregationLevel
                {
                    User = await UserLevel.CreateAsync(currentUserId, userIdCode, EntrancePage.People,
                                                       dbContext, cachedData, userManager)
                };
                break;

            case "aggregation.user.timeline":
                root.Aggregation = new AggregationLevel
                {
                    User = await UserLevel.CreateAsync(currentUserId, userIdCode, EntrancePage.Timeline,
                                                       dbContext, cachedData, userManager)
                };
                break;

            case "aggregation.user.edit":
                root.Aggregation = new AggregationLevel
                {
                    User = await UserLevel.CreateAsync(currentUserId, userIdCode, EntrancePage.Edit,
                                                       dbContext, cachedData, userManager)
                };
                break;

            case "content.article":
                root.Content = new ContentLevel
                {
                    Article =
                        await
                        States.Content.Article.ArticlePage.CreateAsync(authorIdCode, sidForAuthor, currentUserId,
                                                                       isOperator, dbContext, cachedData, userManager)
                };
                break;

            case "content.activity":
                root.Content = new ContentLevel
                {
                    Activity = await ActivityPage.CreateAsync(authorIdCode, sidForAuthor, currentUserId,
                                                              isOperator, dbContext, cachedData, userManager)
                };
                break;

            case "post-office.unread":
                if (await StateTreeHelper.CanAccessAsync <Root>(nameof(PostOffice)))
                {
                    root.PostOffice = new PostOfficeLevel
                    {
                        Unread = await UnreadPage.CreateAsync(currentUserId, dbContext, cachedData)
                    }
                }
                ;
                break;

            case "post-office.social-activity.comment":
                if (await StateTreeHelper.CanAccessAsync <Root>(nameof(PostOffice)))
                {
                    root.PostOffice = new PostOfficeLevel
                    {
                        SocialActivity = new SocialActivityLevel
                        {
                            Comment = await CommentPage.CreateAsync(currentUserId, dbContext, cachedData)
                        }
                    }
                }
                ;
                break;

            case "post-office.social-activity.like":
                if (await StateTreeHelper.CanAccessAsync <Root>(nameof(PostOffice)))
                {
                    root.PostOffice = new PostOfficeLevel
                    {
                        SocialActivity = new SocialActivityLevel
                        {
                            Like = await LikePage.CreateAsync(currentUserId, dbContext, cachedData)
                        }
                    }
                }
                ;
                break;

            case "post-office.social-activity.subscriber":
                if (await StateTreeHelper.CanAccessAsync <Root>(nameof(PostOffice)))
                {
                    root.PostOffice = new PostOfficeLevel
                    {
                        SocialActivity = new SocialActivityLevel
                        {
                            Subscriber = await SubscriberPage.CreateAsync(currentUserId, dbContext, cachedData)
                        }
                    }
                }
                ;
                break;

            case "post-office.missive":
                if (await StateTreeHelper.CanAccessAsync <Root>(nameof(PostOffice)))
                {
                    root.PostOffice = new PostOfficeLevel
                    {
                        Missive = await MissivePage.CreateAsync(currentUserId, dbContext, cachedData)
                    }
                }
                ;
                break;

            case "coupon.detail":
                if (await StateTreeHelper.CanAccessAsync <Root>(nameof(Coupon)))
                {
                    root.Coupon = new CouponLevel
                    {
                        Detail = await DetailPage.CreateAsync(currentUserId, dbContext, userManager)
                    }
                }
                ;
                break;

            case "coupon.store":
                if (await StateTreeHelper.CanAccessAsync <Root>(nameof(Coupon)))
                {
                    root.Coupon = new CouponLevel
                    {
                        Store =
                            await StorePage.CreateAsync(currentUserId, dbContext, cachedData, userManager, coupon)
                    }
                }
                ;
                break;

            case "coupon.ranking":
                if (await StateTreeHelper.CanAccessAsync <Root>(nameof(Coupon)))
                {
                    root.Coupon = new CouponLevel
                    {
                        Ranking = await RankingPage.CreateAsync(currentUserId, dbContext, cachedData)
                    }
                }
                ;
                break;

            case "search.point":
                root.Search = new SearchLevel
                {
                    Point = await PointPage.CreateAsync(currentUserId, keyword, dbContext, cachedData)
                };
                break;

            case "search.article":
                root.Search = new SearchLevel
                {
                    Article = await ArticlePage.CreateAsync(keyword, dbContext, cachedData)
                };
                break;

            case "search.user":
                root.Search = new SearchLevel
                {
                    User = await UserPage.CreateAsync(currentUserId, keyword, dbContext, cachedData)
                };
                break;

            default:
                throw new NotSupportedException("Not supported state.");
            }
            return(root);
        }
Ejemplo n.º 19
0
 /// <summary>
 /// 获取用户听众列表
 /// </summary>
 /// <param name="userId">用户 ID</param>
 /// <param name="page">分页页码</param>
 /// <param name="dbContext"><see cref="KeylolDbContext"/></param>
 /// <param name="cachedData"><see cref="CachedDataProvider"/></param>
 /// <returns><see cref="UserEntryList"/></returns>
 public static async Task <UserEntryList> GetSubscribers(string userId, int page,
                                                         [Injected] KeylolDbContext dbContext, [Injected] CachedDataProvider cachedData)
 {
     return((await UserEntryList.CreateAsync(userId, StateTreeHelper.GetCurrentUserId(),
                                             UserRelationship.Subscriber, false, page, dbContext, cachedData)).Item1);
 }
Ejemplo n.º 20
0
 /// <summary>
 /// 获取文券记录列表
 /// </summary>
 /// <param name="page">分页页码</param>
 /// <param name="dbContext"><see cref="KeylolDbContext"/></param>
 /// <param name="userManager"><see cref="KeylolUserManager"/></param>
 /// <returns><see cref="CouponLogList"/></returns>
 public static async Task <CouponLogList> Get(int page, [Injected] KeylolDbContext dbContext,
                                              [Injected] KeylolUserManager userManager)
 {
     return((await CreateAsync(StateTreeHelper.GetCurrentUserId(), page, false, dbContext, userManager)).Item1);
 }
Ejemplo n.º 21
0
 /// <summary>
 /// 获取时间轴卡片列表
 /// </summary>
 /// <param name="pointId">据点 ID</param>
 /// <param name="before">起始位置</param>
 /// <param name="take">获取数量</param>
 /// <param name="dbContext"><see cref="KeylolDbContext"/></param>
 /// <param name="cachedData"><see cref="CachedDataProvider"/></param>
 /// <returns><see cref="TimelineCardList"/></returns>
 public static async Task <TimelineCardList> GetCards(string pointId, int before, int take,
                                                      [Injected] KeylolDbContext dbContext, [Injected] CachedDataProvider cachedData)
 {
     return(await TimelineCardList.CreateAsync(PointStream.Name(pointId), StateTreeHelper.GetCurrentUserId(),
                                               take, false, dbContext, cachedData, before));
 }
Ejemplo n.º 22
0
 /// <summary>
 /// 搜索用户页面返回结果
 /// </summary>
 /// <param name="keyword">搜索关键字</param>
 /// <param name="dbContext"><see cref="KeylolDbContext"/></param>
 /// <param name="cachedData"><see cref="CachedDataProvider"/></param>
 /// <param name="searchAll">是否全部搜索</param>
 public static async Task <UserPage> Get(string keyword, [Injected] KeylolDbContext dbContext,
                                         [Injected] CachedDataProvider cachedData, bool searchAll = true)
 {
     return(await CreateAsync(StateTreeHelper.GetCurrentUserId(), keyword, dbContext, cachedData, searchAll));
 }
Ejemplo n.º 23
0
 /// <summary>
 /// 获取“入口”层级状态分支
 /// </summary>
 /// <param name="dbContext"><see cref="KeylolDbContext"/></param>
 /// <param name="cachedData"><see cref="CachedDataProvider"/></param>
 /// <returns><see cref="EntranceLevel"/></returns>
 public static async Task <EntranceLevel> Get([Injected] KeylolDbContext dbContext,
                                              [Injected] CachedDataProvider cachedData)
 {
     return(await CreateAsync(StateTreeHelper.GetCurrentUserId(), EntrancePage.Auto,
                              dbContext, cachedData));
 }
Ejemplo n.º 24
0
 /// <summary>
 /// 获取可能感兴趣的据点列表
 /// </summary>
 /// <param name="page">分页页码</param>
 /// <param name="dbContext"><see cref="KeylolDbContext"/></param>
 /// <returns><see cref="InterestedPointList"/></returns>
 public static async Task <InterestedPointList> Get(int page, [Injected] KeylolDbContext dbContext)
 {
     return(await CreateAsync(StateTreeHelper.GetCurrentUserId(), page, dbContext));
 }
Ejemplo n.º 25
0
 /// <summary>
 /// 获取评论消息列表
 /// </summary>
 /// <param name="page">分页页码</param>
 /// <param name="dbContext"><see cref="KeylolDbContext"/></param>
 /// <param name="cachedData"><see cref="CachedDataProvider"/></param>
 /// <returns><see cref="PostOfficeMessageList"/></returns>
 public static async Task <PostOfficeMessageList> GetMessages(int page, [Injected] KeylolDbContext dbContext,
                                                              [Injected] CachedDataProvider cachedData)
 {
     return((await PostOfficeMessageList.CreateAsync(typeof(CommentPage), StateTreeHelper.GetCurrentUserId(),
                                                     page, false, dbContext, cachedData)).Item1);
 }
Ejemplo n.º 26
0
        /// <summary>
        /// 获取当前用户邀请注册数
        /// </summary>
        /// <param name="dbContext"><see cref="KeylolDbContext"/></param>
        /// <returns>邀请注册数</returns>
        public static async Task <int> GetInviteCount([Injected] KeylolDbContext dbContext)
        {
            var currentUserId = StateTreeHelper.GetCurrentUserId();

            return(await dbContext.Users.CountAsync(u => u.InviterId == currentUserId));
        }
Ejemplo n.º 27
0
 /// <summary>
 /// 获取指定动态评论列表(用于轨道卡片)
 /// </summary>
 /// <param name="activityId">动态 ID</param>
 /// <param name="take">获取数量</param>
 /// <param name="dbContext"><see cref="KeylolDbContext"/></param>
 /// <param name="cachedData"><see cref="CachedDataProvider"/></param>
 /// <param name="before">起始位置</param>
 /// <returns><see cref="ActivityCommentList"/></returns>
 public static async Task <ActivityCommentList> GetComments(string activityId, int take,
                                                            [Injected] KeylolDbContext dbContext, [Injected] CachedDataProvider cachedData, int before = int.MaxValue)
 {
     return(await ActivityCommentList.CreateAsync(activityId, StateTreeHelper.GetCurrentUserId(),
                                                  before, take, StateTreeHelper.GetCurrentUser().IsInRole(KeylolRoles.Operator), dbContext, cachedData));
 }