feat: scan book to add to sell
This commit is contained in:
parent
3a013c829f
commit
07c7c98edb
11 changed files with 238 additions and 31 deletions
|
|
@ -55,6 +55,13 @@ class BalRepository {
|
|||
false;
|
||||
}
|
||||
|
||||
Future<Bal?> ongoingBal() async {
|
||||
if (_bals == null) {
|
||||
await _getBalsNoCache();
|
||||
}
|
||||
return _bals!.where((bal) => bal.state == BalState.ongoing).firstOrNull;
|
||||
}
|
||||
|
||||
Future<Result<Bal>> stopBal(int id) async {
|
||||
final result = await _apiClient.stopBal(id);
|
||||
_getBalsNoCache();
|
||||
|
|
|
|||
|
|
@ -11,6 +11,10 @@ class BookInstanceRepository {
|
|||
|
||||
final ApiClient _apiClient;
|
||||
|
||||
Future<Result<List<BookInstance>>> getByEan(int balId, int ean) async {
|
||||
return await _apiClient.getBookInstanceByEAN(balId, ean);
|
||||
}
|
||||
|
||||
Future<Result<BookInstance>> sendBook(
|
||||
Book book,
|
||||
Owner owner,
|
||||
|
|
|
|||
|
|
@ -8,6 +8,10 @@ class BookRepository {
|
|||
final ApiClient _apiClient;
|
||||
|
||||
Future<Result<Book>> getBookByEAN(String ean) async {
|
||||
return _apiClient.getBookByEAN(ean);
|
||||
return await _apiClient.getBookByEAN(ean);
|
||||
}
|
||||
|
||||
Future<Result<Book>> getBookById(int id) async {
|
||||
return await _apiClient.getBookById(id);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,6 +33,18 @@ class OwnerRepository {
|
|||
return result;
|
||||
}
|
||||
|
||||
Future<Result<Owner>> getOwnerById(int id) async {
|
||||
if (_cachedOwners != null) {
|
||||
final result1 = _cachedOwners!
|
||||
.where((owner) => owner.id == id)
|
||||
.firstOrNull;
|
||||
if (result1 != null) {
|
||||
return Result.ok(result1);
|
||||
}
|
||||
}
|
||||
return await _apiClient.getOwnerById(id);
|
||||
}
|
||||
|
||||
/// Adds an [Owner] to the database, and gets the resulting [Owner].
|
||||
Future<Result<Owner>> addOwner(
|
||||
String firstName,
|
||||
|
|
|
|||
Reference in a new issue