import 'package:ambito/src/domain/entity/baumarten/baumarten.dart';
import 'package:ambito/src/domain/entity/massnahme/massnahme.dart';
import 'package:isar/isar.dart';

import '../../../main.dart';

class BaseDB {
  static put(var entity) {
    switch (entity.runtimeType) {
      case 'Baumarten':
        isar.write((isar) {
          isar.baumartens.put(entity);
        });
        break;
      case 'Massnahme':
        isar.write((isar) {
          isar.massnahmes.put(entity);
        });
        break;
    }
  }

  static getAll(String type) {
    switch (type) {
      case 'Maßnahme':
        return isar.massnahmes.where().sortByName().findAll();
      case 'Baumart':
        return isar.baumartens.where().findAll();
    }
  }
}
