Example #1
0
        private void UpdateInfo(Category cat, DalCategory dalCat)
        {
            if (cat == null || dalCat == null) throw new ArgumentNullException();

            cat.Id = dalCat.Id;
            cat.Name = dalCat.Name;
            cat.Description = dalCat.Description;
            cat.DateCreated = dalCat.DateCreated;
            cat.Category_Id = dalCat.ParentCategoryId;
        }
Example #2
0
        private Category ToOrmCategory(DalCategory cat)
        {
            if (cat == null) return null;

            var topics = cat.Topics ?? new List<DalTopic>();

            var dbSetTopics = _context.Set<Topic>();

            var actualTopics = topics.Select(t => dbSetTopics.SingleOrDefault(tt => tt.Id == t.Id)).ToList();

            var newCat = new Category {Topics = actualTopics};
            UpdateInfo(newCat, cat);

            return newCat;
        }