import 'package:diplomaticquarterapp/core/enum/viewstate.dart';
import 'package:diplomaticquarterapp/core/model/er/projectavgerwaitingtime.dart';
import 'package:diplomaticquarterapp/core/service/er/er_service.dart';
import 'package:diplomaticquarterapp/core/viewModels/base_view_model.dart';

import '../../../locator.dart';

class NearHospitalViewModel extends BaseViewModel {
  ErService _erService = locator<ErService>();

  List<ProjectAvgERWaitingTime> get ProjectAvgERWaitingTimeModeList =>
      _erService.projectAvgERWaitingTimeModelList;

  getProjectAvgERWaitingTimeOrders({int id, int projectID}) async {
    setState(ViewState.Busy);

    if (id != null && projectID != null) {
      await _erService.getProjectAvgERWaitingTimeOrders(
          id: id, projectID: projectID);
    } else {
      await _erService.getProjectAvgERWaitingTimeOrders();
    }
    if (_erService.hasError) {
      error = _erService.error;
      setState(ViewState.Error);
    } else
      setState(ViewState.Idle);
  }
}
