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; }
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; }