37 lines
		
	
	
	
		
			889 B
		
	
	
	
		
			Dart
		
	
	
	
	
	
			
		
		
	
	
			37 lines
		
	
	
	
		
			889 B
		
	
	
	
		
			Dart
		
	
	
	
	
	
import 'package:diameter/main.dart';
 | 
						|
import 'package:diameter/objectbox.g.dart';
 | 
						|
 | 
						|
@Entity()
 | 
						|
class BolusProfile {
 | 
						|
  static final Box<BolusProfile> box = objectBox.store.box<BolusProfile>();
 | 
						|
 | 
						|
  int id;
 | 
						|
  String name;
 | 
						|
  bool active;
 | 
						|
  String? notes;
 | 
						|
 | 
						|
  BolusProfile({
 | 
						|
    this.id = 0,
 | 
						|
    this.name = '',
 | 
						|
    this.active = false,
 | 
						|
    this.notes,
 | 
						|
  });
 | 
						|
 | 
						|
  static BolusProfile? get(int id) => box.get(id);
 | 
						|
  static List<BolusProfile> getAll() => box.getAll();
 | 
						|
  static void put(BolusProfile bolusProfile) => box.put(bolusProfile);
 | 
						|
  static void remove(int id) => box.remove(id);
 | 
						|
 | 
						|
  static int activeCount() {
 | 
						|
    Query<BolusProfile> query =
 | 
						|
        box.query(BolusProfile_.active.equals(true)).build();
 | 
						|
    return query.find().length;
 | 
						|
  }
 | 
						|
 | 
						|
  static void setAllInactive() {
 | 
						|
    box.putMany(box.getAll().map((element) {
 | 
						|
      element.active = false;
 | 
						|
      return element;
 | 
						|
    }).toList());
 | 
						|
  }
 | 
						|
}
 |