示例#1
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
        }
示例#2
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
        }