Example #1
0
        public override IEnumerable <ICategory> GetAllCategories()
        {
            _table.InitializeDatabase();
            var lines         = _table.SelectAll().ToArray();
            var withNoParents = lines.Select(objects => ObjectToICategoryConverter.Convert(objects, CategoryFactory)).ToArray();

            foreach (var line in lines)
            {
                ObjectToICategoryConverter.UpdateParents(line, withNoParents);
            }
            return(withNoParents.ToList());
        }
Example #2
0
 public override ICategory CreateCategory(ICategory category)
 {
     _table.InitializeDatabase();
     if (category.Id == 0)
     {
         category.Id = _table.AddData(ObjectToICategoryConverter.ConvertToKeyPairList(category));
     }
     else
     {
         _table.AddData(ObjectToICategoryConverter.ConvertToKeyPairListWithId(category));
     }
     return(category);
 }
Example #3
0
 public override void UpdateCategory(ICategory category)
 {
     _table.InitializeDatabase();
     _table.UpdateData(ObjectToICategoryConverter.ConvertToKeyPairList(category), category.Id);
 }