Livecardrework (#104)
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import 'dart:convert';
|
||||
import 'package:filcnaplo/models/subject_lesson_count.dart';
|
||||
import 'package:sqflite_common/sqlite_api.dart';
|
||||
|
||||
// Models
|
||||
@@ -12,6 +13,7 @@ import 'package:filcnaplo_kreta_api/models/message.dart';
|
||||
import 'package:filcnaplo_kreta_api/models/note.dart';
|
||||
import 'package:filcnaplo_kreta_api/models/event.dart';
|
||||
import 'package:filcnaplo_kreta_api/models/absence.dart';
|
||||
import 'package:filcnaplo_kreta_api/models/group_average.dart';
|
||||
|
||||
class DatabaseStore {
|
||||
DatabaseStore({required this.db});
|
||||
@@ -43,43 +45,54 @@ class UserDatabaseStore {
|
||||
|
||||
final Database db;
|
||||
|
||||
Future storeGrades(List<Grade> grades, {required String userId}) async {
|
||||
Future<void> storeGrades(List<Grade> grades, {required String userId}) async {
|
||||
String gradesJson = jsonEncode(grades.map((e) => e.json).toList());
|
||||
await db.update("user_data", {"grades": gradesJson}, where: "id = ?", whereArgs: [userId]);
|
||||
}
|
||||
|
||||
Future storeLessons(List<Lesson> lessons, {required String userId}) async {
|
||||
Future<void> storeLessons(List<Lesson> lessons, {required String userId}) async {
|
||||
String lessonsJson = jsonEncode(lessons.map((e) => e.json).toList());
|
||||
await db.update("user_data", {"timetable": lessonsJson}, where: "id = ?", whereArgs: [userId]);
|
||||
}
|
||||
|
||||
Future storeExams(List<Exam> exams, {required String userId}) async {
|
||||
Future<void> storeExams(List<Exam> exams, {required String userId}) async {
|
||||
String examsJson = jsonEncode(exams.map((e) => e.json).toList());
|
||||
await db.update("user_data", {"exams": examsJson}, where: "id = ?", whereArgs: [userId]);
|
||||
}
|
||||
|
||||
Future storeHomework(List<Homework> homework, {required String userId}) async {
|
||||
Future<void> storeHomework(List<Homework> homework, {required String userId}) async {
|
||||
String homeworkJson = jsonEncode(homework.map((e) => e.json).toList());
|
||||
await db.update("user_data", {"homework": homeworkJson}, where: "id = ?", whereArgs: [userId]);
|
||||
}
|
||||
|
||||
Future storeMessages(List<Message> messages, {required String userId}) async {
|
||||
Future<void> storeMessages(List<Message> messages, {required String userId}) async {
|
||||
String messagesJson = jsonEncode(messages.map((e) => e.json).toList());
|
||||
await db.update("user_data", {"messages": messagesJson}, where: "id = ?", whereArgs: [userId]);
|
||||
}
|
||||
|
||||
Future storeNotes(List<Note> notes, {required String userId}) async {
|
||||
Future<void> storeNotes(List<Note> notes, {required String userId}) async {
|
||||
String notesJson = jsonEncode(notes.map((e) => e.json).toList());
|
||||
await db.update("user_data", {"notes": notesJson}, where: "id = ?", whereArgs: [userId]);
|
||||
}
|
||||
|
||||
Future storeEvents(List<Event> events, {required String userId}) async {
|
||||
Future<void> storeEvents(List<Event> events, {required String userId}) async {
|
||||
String eventsJson = jsonEncode(events.map((e) => e.json).toList());
|
||||
await db.update("user_data", {"events": eventsJson}, where: "id = ?", whereArgs: [userId]);
|
||||
}
|
||||
|
||||
Future storeAbsences(List<Absence> absences, {required String userId}) async {
|
||||
Future<void> storeAbsences(List<Absence> absences, {required String userId}) async {
|
||||
String absencesJson = jsonEncode(absences.map((e) => e.json).toList());
|
||||
await db.update("user_data", {"absences": absencesJson}, where: "id = ?", whereArgs: [userId]);
|
||||
}
|
||||
|
||||
Future<void> storeGroupAverages(List<GroupAverage> groupAverages, {required String userId}) async {
|
||||
String groupAveragesJson = jsonEncode(groupAverages.map((e) => e.json).toList());
|
||||
await db.update("user_data", {"group_averages": groupAveragesJson}, where: "id = ?", whereArgs: [userId]);
|
||||
}
|
||||
|
||||
|
||||
Future<void> storeSubjectLessonCount(SubjectLessonCount lessonCount, {required String userId}) async {
|
||||
String lessonCountJson = jsonEncode(lessonCount.toMap());
|
||||
await db.update("user_data", {"subject_lesson_count": lessonCountJson}, where: "id = ?", whereArgs: [userId]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user