Example #1
0
 public void Delete(DalTopic entity)
 {
     if (entity == null) throw new ArgumentNullException("entity");
     Delete(entity.Id);
 }
Example #2
0
        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;
        }
Example #3
0
 public void Update(DalTopic entity)
 {
     if (entity == null) throw new ArgumentNullException("entity");
     var existedEntity = _dbSetTopics.Find(entity.Id);
     UpdateInfo(existedEntity, entity);
 }
Example #4
0
        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;
        }
Example #5
0
 public void Insert(DalTopic entity)
 {
     if (entity == null) throw new ArgumentNullException("entity");
     _dbSetTopics.Add(ToOrmTopic(entity));
 }