Пример #1
0
        /// <summary>
        /// 删除主题
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public bool DeleteBy(int id)
        {
            if (CurrenUser.Id == 0)
            {
                throw new Exception("异常人员删除主题,记录");
            }
            ContentTopicEntity topicEntity = _topicRepository.Find(id);

            topicEntity.Delete(CurrenUser);
            return(true);
        }
Пример #2
0
        public void AddNewTopic(TopicModel model)
        {
            //Save Content of topic
            ContentTopicEntity topic = Mapper.Map <ContentTopicEntity>(model);
            int id = _topicRepository.Insert(topic.Publish(CurrenUser));

            #region Video In Topic
            IList <TopicAndVideoEntity> insertData = TopicAndVideoEntity.GetMiddleListBy(model.Videos, id);
            if (insertData.Count > 0)
            {
                _topicAndVideoRepository.Insert(insertData);
            }
            #endregion
        }
Пример #3
0
        public TopicModel GetSpecifiedTopicBy(int id)
        {
            if (CurrenUser == null)
            {
                throw new Exception("请登录后重试!");
            }
            ContentTopicEntity entity = _topicRepository.Find(id);
            TopicModel         model  = Mapper.Map <TopicModel>(entity);

            foreach (var item in entity.Videos)
            {
                model.Videos += "," + item.VideoEntity.Id;
            }
            return(model);
        }
Пример #4
0
        public void UpdateTopic(TopicModel topicModel)
        {
            ContentTopicEntity topic = _topicRepository.Find(topicModel.Id);

            topic.Update(CurrenUser);
            topic.Name = topicModel.Name;
            #region Video In Topic
            //Find before exist middle content and remove ,add new one;
            IList <TopicAndVideoEntity> topicVideo = _topicAndVideoRepository.GetTopicVideoBy(topic.Id);
            _topicAndVideoRepository.RemoveBy(topicVideo);
            IList <TopicAndVideoEntity> insertData = TopicAndVideoEntity.GetMiddleListBy(topicModel.Videos, topic.Id);
            if (insertData.Count > 0)
            {
                _topicAndVideoRepository.Insert(insertData);
            }
            #endregion
        }