Пример #1
0
        public void UpdateSubCategory(SubCategory category)
        {
            var newCategory = ModelConvertor.Convert(category);

            _context.SubCategories.Update(newCategory);
            _context.SaveChanges();
        }
Пример #2
0
        public void AddCategory(Category category)
        {
            var newCategory = ModelConvertor.Convert(category);

            _context.Categories.Add(newCategory);

            _context.SaveChanges();
        }
Пример #3
0
 public IEnumerable <SubCategory> GetAllSubCategories()
 {
     return(Array.ConvertAll(_context.SubCategories.ToArray(), (c) =>
     {
         var sc = ModelConvertor.Convert(c);
         sc.CategoryId = c.Id;
         return sc;
     }));
 }
Пример #4
0
        public void AddSubCategory(SubCategory category)
        {
            var newSCategory = ModelConvertor.Convert(category);

            newSCategory.Category = _context.Categories.FirstOrDefault(f => f.Id == category.Id);

            _context.Add(newSCategory);

            _context.SaveChanges();
        }
Пример #5
0
 public SubCategory GetSubCategoryByID(Guid id)
 {
     return(ModelConvertor.Convert(_context.SubCategories.FirstOrDefault(f => f.Id == id)));
 }
Пример #6
0
 public IEnumerable <Category> GetAllCategories()
 {
     return(Array.ConvertAll(_context.Categories.ToArray(), (c) => ModelConvertor.Convert(c)));
 }