public void AddCategory([FromBody] string category)
 {
     try
     {
         CategoriesDB _category           = new CategoriesDB();
         string       categoryToAddString = category;
         string[]     elements            = categoryToAddString.Split(',');
         foreach (string it in elements)
         {
             string _categoryName = elements[0];
             _category.categoryName = _categoryName;
         }
         using (var context = new Data.Smart_Saver_APIContext())
         {
             context.CategoriesDB.Add(_category);
             context.SaveChanges();
         }
     }
     catch (Exception e)
     {
         _logger.LogError(e.ToString());
     }
 }
 public void OnGet()
 {
     Categories = CategoriesDB.GetCategories(_configuration);
 }
Beispiel #3
0
 public void OnGet(int id)
 {
     Product  = ProductsDB.GetProduct(id, _configuration);
     Category = CategoriesDB.GetCategory(Product.IdCategory, _configuration);
 }
Beispiel #4
0
 public Categories()
 {
     categoriesDB = new CategoriesDB();
 }