Beispiel #1
0
        /// <summary>
        /// 设置用户数据库
        /// </summary>
        /// <param name="database">数据库</param>
        /// <returns></returns>
        public async Task SetDatabase(IAccountRepository database)
        {
            db = database;

            //获取控制器
            SubscriberController subscriberController = new SubscriberController(database.Subscribers);
            TopicController topicController = new TopicController(database);

            //填充数据
            instance.SubscriberList = await subscriberController.GetSubscribers();
            instance.TopicList = await topicController.GetTopics();
        }
Beispiel #2
0
        /// <summary>
        /// 设置话题对象
        /// </summary>
        /// <param name="topic">话题</param>
        /// <returns></returns>
        public async Task SetTopic(Topic topic)
        {
            instance = topic;

            //初始化消息列表
            MessageController  messageController = new MessageController(db.Messages);
            List <ChatMessage> messages          = await messageController.GetMessages(instance, instance.Limit);

            messages.ForEach(async m => await AddMessage(m));

            //初始化话题订阅者列表
            SubscriberController subscriberController = new SubscriberController(db.Subscribers);

            instance.SubsriberList = await subscriberController.GetSubscribers(instance);
        }