コード例 #1
0
ファイル: TopicRepository.cs プロジェクト: Alukar/ForumMVC
 public void Delete(DalTopic entity)
 {
     if (entity == null) throw new ArgumentNullException("entity");
     Delete(entity.Id);
 }
コード例 #2
0
ファイル: TopicRepository.cs プロジェクト: Alukar/ForumMVC
        private void UpdateInfo(Topic topic, DalTopic dalTopic)
        {
            if (topic == null || dalTopic == null) throw new ArgumentNullException();

            topic.Id = dalTopic.Id;
            topic.Category_Id = dalTopic.CategoryId;
            topic.MembershipUser_Id = dalTopic.User.Id;
            topic.Name = dalTopic.Name;
            topic.CreateDate = dalTopic.CreateDate;
        }
コード例 #3
0
ファイル: TopicRepository.cs プロジェクト: Alukar/ForumMVC
 public void Update(DalTopic entity)
 {
     if (entity == null) throw new ArgumentNullException("entity");
     var existedEntity = _dbSetTopics.Find(entity.Id);
     UpdateInfo(existedEntity, entity);
 }
コード例 #4
0
ファイル: TopicRepository.cs プロジェクト: Alukar/ForumMVC
        private Topic ToOrmTopic(DalTopic topic)
        {
            if (topic == null) return null;
            var topictags = topic.TopicTags ?? new List<DalTopicTag>();

            var dbSetTopicTag = _context.Set<TopicTag>();

            var actualTags = topictags.Select(tag => dbSetTopicTag.SingleOrDefault(tt => tt.Id == tag.Id)).ToList();
            var newTopic = new Topic()
            {
                TopicTags = actualTags,
            };
            UpdateInfo(newTopic, topic);
            return newTopic;
        }
コード例 #5
0
ファイル: TopicRepository.cs プロジェクト: Alukar/ForumMVC
 public void Insert(DalTopic entity)
 {
     if (entity == null) throw new ArgumentNullException("entity");
     _dbSetTopics.Add(ToOrmTopic(entity));
 }