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