exam.dart 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. import 'dart:convert';
  2. import 'package:fis_jsonrpc/rpc.dart';
  3. import 'package:vitalapp/managers/interfaces/exam.dart';
  4. import 'package:vitalapp/rpc.dart';
  5. import 'package:vitalapp/store/store.dart';
  6. import 'package:fis_common/logger/logger.dart';
  7. class ExamManager implements IExamManager {
  8. @override
  9. Future<bool?> createExam(CreateExamRequest examRequest) async {
  10. try {
  11. examRequest.token = Store.user.token;
  12. final examCode = await rpc.exam.createExamAsync(
  13. examRequest,
  14. );
  15. print(jsonEncode(examRequest.toJson()));
  16. if (examCode.isNotEmpty) {
  17. return true;
  18. }
  19. return false;
  20. } catch (e) {
  21. logger.e("ExamManager sync user info error.", e);
  22. return null;
  23. }
  24. }
  25. @override
  26. Future<bool?> editExam(UpdateExamRequest examRequest) async {
  27. try {
  28. examRequest.token = Store.user.token;
  29. final result = await rpc.exam.updateExamAsync(
  30. examRequest,
  31. );
  32. return result;
  33. } catch (e) {
  34. logger.e("ExamManager sync user info error.", e);
  35. return null;
  36. }
  37. }
  38. @override
  39. Future<bool?> updateExamByBatchNumberAsync(
  40. UpdateExamByBatchNumberRequest updateExamByBatchNumberRequest) async {
  41. try {
  42. updateExamByBatchNumberRequest.token = Store.user.token;
  43. final result = await rpc.exam.updateExamByBatchNumberAsync(
  44. updateExamByBatchNumberRequest,
  45. );
  46. print(jsonEncode(updateExamByBatchNumberRequest.toJson()));
  47. return result;
  48. } catch (e) {
  49. logger.e("updateExamByBatchNumberAsync sync user info error.", e);
  50. return null;
  51. }
  52. }
  53. }