Aidra Connect 10.0.2+16
Aidra Connect Mobile Application
Loading...
Searching...
No Matches
elearning_v2_repository_impl.dart
Go to the documentation of this file.
1import 'package:dartz/dartz.dart';
2
3import '../../../../core/errors/exception_failure_adapter.dart';
4import '../../../../core/errors/failures.dart';
5import '../../domain/entities/course_entity.dart';
6import '../../domain/entities/qcm_entity.dart';
7import '../../domain/repository/elearning_v2_repository.dart';
8import '../data_sources/elearning_v2_local_data_source.dart';
9
12
13 ElearningV2RepositoryImpl({required this.localDataSource});
14
15 @override
16 Future<Either<Failure, List<CourseEntity>>> getCourses() async {
17 try {
18 final courses = await localDataSource.getCourses();
19 return Right(courses);
20 } catch (e) {
21 return Left(ExceptionFailureAdapter.adapt(e));
22 }
23 }
24
25 @override
26 Future<Either<Failure, CourseEntity>> getCourseDetails(int courseId) async {
27 try {
28 final course = await localDataSource.getCourseDetails(courseId);
29 return Right(course);
30 } catch (e) {
31 return Left(ExceptionFailureAdapter.adapt(e));
32 }
33 }
34
35 @override
36 Future<Either<Failure, List<QcmEntity>>> getQcmForCourse(int courseId) async {
37 try {
38 final qcmList = await localDataSource.getQcmForCourse(courseId);
39 return Right(qcmList);
40 } catch (e) {
41 return Left(ExceptionFailureAdapter.adapt(e));
42 }
43 }
44
45 @override
46 Future<Either<Failure, String>> getPdfPathForCourse(int courseId) async {
47 try {
48 final pdfPath = await localDataSource.getPdfPathForCourse(courseId);
49 return Right(pdfPath);
50 } catch (e) {
51 return Left(ExceptionFailureAdapter.adapt(e));
52 }
53 }
54
55 @override
56 Future<Either<Failure, bool>> updateCourseProgress(
57 int courseId, double progress) async {
58 try {
59 final result =
60 await localDataSource.updateCourseProgress(courseId, progress);
61 return Right(result);
62 } catch (e) {
63 return Left(ExceptionFailureAdapter.adapt(e));
64 }
65 }
66}
override Future< Either< Failure, List< CourseEntity > > > getCourses() async
final ElearningV2LocalDataSource localDataSource
override Future< Either< Failure, List< QcmEntity > > > getQcmForCourse(int courseId) async
ElearningV2RepositoryImpl({required this.localDataSource})
override Future< Either< Failure, bool > > updateCourseProgress(int courseId, double progress) async
override Future< Either< Failure, String > > getPdfPathForCourse(int courseId) async
override Future< Either< Failure, CourseEntity > > getCourseDetails(int courseId) async
static Failure adapt(dynamic exception)
final String pdfPath
class CoursesLoadingFailureState extends ElearningV2State course
abstract class ElearningV2State extends Equatable courses
final List< QcmEntity > qcmList
class GetPdfPathUseCase implements UseCase< String, PdfParams > courseId
final double progress