38 lines
901 B
Dart
38 lines
901 B
Dart
import '../api/notes_api.dart';
|
|
import '../models/note.dart';
|
|
|
|
class NotesRepository {
|
|
final NotesApi _api;
|
|
const NotesRepository(this._api);
|
|
|
|
Future<List<Note>> getAll() => _api.getAll();
|
|
Future<Note> getOne(int id) => _api.getOne(id);
|
|
|
|
Future<Note> create(
|
|
String title,
|
|
String body, {
|
|
List<String> tags = const [],
|
|
int? projectId,
|
|
String noteType = 'note',
|
|
}) =>
|
|
_api.create(title, body,
|
|
tags: tags, projectId: projectId, noteType: noteType);
|
|
|
|
Future<Note> update(
|
|
int id,
|
|
String title,
|
|
String body, {
|
|
List<String> tags = const [],
|
|
int? projectId,
|
|
bool clearProject = false,
|
|
String noteType = 'note',
|
|
}) =>
|
|
_api.update(id, title, body,
|
|
tags: tags,
|
|
projectId: projectId,
|
|
clearProject: clearProject,
|
|
noteType: noteType);
|
|
|
|
Future<void> delete(int id) => _api.delete(id);
|
|
}
|