You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
1.1 KiB
Dart
25 lines
1.1 KiB
Dart
4 years ago
|
import 'package:diplomaticquarterapp/core/enum/viewstate.dart';
|
||
|
import 'package:diplomaticquarterapp/core/model/notifications/get_notifications_request_model.dart';
|
||
|
import 'package:diplomaticquarterapp/core/model/notifications/get_notifications_response_model.dart';
|
||
|
import 'package:diplomaticquarterapp/core/service/notifications_service.dart';
|
||
|
|
||
|
import '../../locator.dart';
|
||
|
import 'base_view_model.dart';
|
||
|
|
||
|
class NotificationViewModel extends BaseViewModel {
|
||
|
NotificationService _notificationService =
|
||
|
locator<NotificationService>();
|
||
|
|
||
|
List<GetNotificationsResponseModel> get notifications => _notificationService.notificationsList;
|
||
|
|
||
|
Future getNotifications() async {
|
||
|
setState(ViewState.Busy);
|
||
|
GetNotificationsRequestModel getNotificationsRequestModel = new GetNotificationsRequestModel(currentPage: 0,pagingSize: 14,notificationStatusID: 2);
|
||
|
await _notificationService.getAllNotifications(getNotificationsRequestModel);
|
||
|
if (_notificationService.hasError) {
|
||
|
error = _notificationService.error;
|
||
|
setState(ViewState.Error);
|
||
|
} else
|
||
|
setState(ViewState.Idle);
|
||
|
}
|
||
|
}
|