exam.dart 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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.vitalExam.createExamAsync(
  13. examRequest,
  14. );
  15. print(jsonEncode(examRequest.toJson()));
  16. if (examCode.isNotEmpty) {
  17. return true;
  18. }
  19. return false;
  20. } catch (e) {
  21. print(jsonEncode(examRequest.toJson()));
  22. logger.e("ExamManager sync user info error.", e);
  23. return null;
  24. }
  25. }
  26. @override
  27. Future<bool?> editExam(UpdateExamRequest examRequest) async {
  28. try {
  29. examRequest.token = Store.user.token;
  30. final result = await rpc.vitalExam.updateExamAsync(
  31. examRequest,
  32. );
  33. return result;
  34. } catch (e) {
  35. logger.e("ExamManager sync user info error.", e);
  36. return null;
  37. }
  38. }
  39. @override
  40. Future<bool?> updateExamByBatchNumberAsync(
  41. UpdateExamByBatchNumberRequest updateExamByBatchNumberRequest) async {
  42. try {
  43. updateExamByBatchNumberRequest.token = Store.user.token;
  44. final result = await rpc.vitalExam.updateExamByBatchNumberAsync(
  45. updateExamByBatchNumberRequest,
  46. );
  47. print(jsonEncode(updateExamByBatchNumberRequest.toJson()));
  48. return result;
  49. } catch (e) {
  50. logger.e("updateExamByBatchNumberAsync sync user info error.", e);
  51. return null;
  52. }
  53. }
  54. }