Skip to content
Snippets Groups Projects
Commit f4336082 authored by Florian's avatar Florian
Browse files

implemented ability to create, update, delete category

parent 0eff6bd3
No related branches found
No related tags found
No related merge requests found
...@@ -7,18 +7,34 @@ class CategoriesController { ...@@ -7,18 +7,34 @@ class CategoriesController {
Box<Category> catBox; Box<Category> catBox;
Map<dynamic, Category> categories; Map<dynamic, Category> categories;
void saveCategory() { Future<bool> saveCategory(Category category) async {
// TODO: implement save categories function // String id = category.title.replaceAll(' ', '_').toLowerCase();
return; try {
await catBox.put(category.id, category);
categories[category.id] = category;
} catch (e) {
return false;
}
return true;
} }
void updateCategory() { Future<bool> updateCategory(Category category) async {
// TODO: implement update category try {
return; await catBox.put(category.id, category);
categories[category.id] = category;
} catch (e) {
return false;
}
return true;
} }
void deleteCategory() { Future<bool> deleteCategory(String id) async {
// TODO: implement read categories function try {
return; await catBox.delete(id);
categories.remove(id);
} catch (e) {
return false;
}
return true;
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment