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 {
Box<Category> catBox;
Map<dynamic, Category> categories;
void saveCategory() {
// TODO: implement save categories function
return;
Future<bool> saveCategory(Category category) async {
// String id = category.title.replaceAll(' ', '_').toLowerCase();
try {
await catBox.put(category.id, category);
categories[category.id] = category;
} catch (e) {
return false;
}
return true;
}
void updateCategory() {
// TODO: implement update category
return;
Future<bool> updateCategory(Category category) async {
try {
await catBox.put(category.id, category);
categories[category.id] = category;
} catch (e) {
return false;
}
return true;
}
void deleteCategory() {
// TODO: implement read categories function
return;
Future<bool> deleteCategory(String id) async {
try {
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