Esempio n. 1
0
        public async Task CreateRecommendFromProject(ProjectCreatedIntegraitionEvent @event)
        {
            var fromUser = await _userService.GetBaseUserInfoAsync(@event.UserId);

            var contacts = await _contactService.GetContactsByUserId(@event.UserId);

            var recommends = contacts.Select(c => new ProjectRecommend
            {
                FromUserId     = @event.UserId,
                Company        = @event.Company,
                Tags           = @event.Tags,
                ProjectId      = @event.ProjectId,
                ProjectAvatar  = @event.ProjectAvatar,
                FinStage       = @event.FinStage,
                RecommendTime  = DateTime.Now,
                CreateTime     = @event.CreatedTime,
                Introduction   = @event.Introduction,
                RecommendType  = EnumRecommendType.Friend,
                FromUserAvatar = fromUser.Avatar,
                FromUserName   = fromUser.Name,
                UserId         = c.UserId
            });

            await _context.ProjectRecommends.AddRangeAsync(recommends);

            await _context.SaveChangesAsync();
        }
Esempio n. 2
0
        public async Task CreateRecommendFromProject(ProjectCreatedintegrationEvent @event)
        {
            var fromUser = await _userService.GetBaseUserInfoAsync(@event.UserId);

            var contacts = await _contactService.GetContactsByUserId(@event.UserId);

            foreach (var contact in contacts)
            {
                var recommend = new ProjectRecommend()
                {
                    FromUserId     = @event.UserId,
                    Company        = @event.Company,
                    Tags           = @event.Tags,
                    ProjectId      = @event.ProjectId,
                    PrjectAvatar   = @event.PrjectAvatar,
                    FinStage       = @event.FinStage,
                    RecommendTime  = @event.CreateTime,
                    CreatedTime    = @event.CreateTime,
                    Introduction   = @event.Introduction,
                    RecommendType  = EnumRecommendType.Friend,
                    FromUserAvatar = fromUser.Avatar,
                    FromUserName   = fromUser.Name,

                    UserId = contact.UserId
                };
                _dbContext.Recommends.Add(recommend);
            }
            await _dbContext.SaveChangesAsync();
        }
        // [CapSubscribe ("finbook.projectapi.projectJoined")]
        // [CapSubscribe ("finbook.projectapi.projectviewed")]
        public async Task CreateRecommendFromProject(ProjectCreatedIntegrationEvent @events)
        {
            //获取用户服务,获取创建项目的用户信息
            var fromUser = await userService.GetBaseUserInfoAsync(@events.UserId);

            //获取联系人服务的用户通讯录信息
            var contacs = await contactService.GetContactsByUserId(@events.UserId);

            //遍历通讯录发布创建项目通知
            foreach (var contact in contacs)
            {
                //项目的推送消息
                var recommend = new ProjectRecommend {
                    FromUserId     = @events.UserId,
                    Company        = @events.Company,
                    Tags           = @events.Tags,
                    ProjectId      = @events.ProjectId,
                    ProjectAvatar  = @events.ProjectAvatar,
                    FinStage       = @events.FinStage,
                    RecommendTime  = DateTime.Now,
                    CreateTime     = @events.CreatedTime,
                    Introduction   = @events.Introduction,
                    RecommendType  = EnumRecommendType.Friend,
                    FromUserAvatar = fromUser.Avatar,
                    FromUserName   = fromUser.Name,
                    UserId         = contact.UserId
                };
                dbContext.Recommends.Add(recommend);
            }
            await dbContext.SaveChangesAsync();
        }
Esempio n. 4
0
        public async Task CreateRecommendFromProjectAsync(ProjectCreatedIntergrationEvent @event)
        {
            //调用UserApi 服务,获取项目创建人信息
            var userinfo = await _userService.GetBaseUserInfoAsync(@event.UserId);

            //调用ContactApi 获取项目创建者的 好友信息
            var friendIds = await _contactService.GetContactsByUserIdAsync(@event.UserId);


            foreach (var item in friendIds)
            {
                var recommend = new ProjectRecommend
                {
                    FromUserId     = @event.UserId,
                    Company        = @event.Company,
                    Tags           = @event.Tags,
                    ProjectId      = @event.ProjectId,
                    FinStage       = @event.FinStage,
                    ProjectAvatar  = @event.ProjectAvatar,
                    CreatedTime    = @event.CreatedTime,
                    Introducation  = @event.Introducation,
                    RecommendType  = EnumRecommendType.Friend,
                    RecommendTime  = DateTime.Now,
                    FromUserAvatar = userinfo.Avatar,
                    FromUserName   = userinfo.Name,
                    UserId         = item.UserId
                };

                _dbContext.ProjectRecommends.Add(recommend);
            }
            await _dbContext.SaveChangesAsync();
        }