|
|
|
@ -2,6 +2,8 @@ import 'package:diplomaticquarterapp/config/config.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/config/shared_pref_kay.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/core/service/AuthenticatedUserObject.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/core/service/client/base_app_client.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/models/Appointments/toDoCountProviderModel.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/models/Authentication/authenticated_user.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/models/Authentication/check_activation_code_request.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/models/Authentication/check_activation_code_request_register.dart';
|
|
|
|
@ -14,9 +16,12 @@ import 'package:diplomaticquarterapp/models/Authentication/register_user_requet.
|
|
|
|
|
import 'package:diplomaticquarterapp/models/Authentication/registered_authenticated_user_req.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/models/Authentication/select_device_imei_res.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/models/Request.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/routes.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart';
|
|
|
|
|
import 'package:flutter/cupertino.dart';
|
|
|
|
|
import 'package:intl/intl.dart';
|
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
|
|
|
|
|
import '../../locator.dart';
|
|
|
|
|
|
|
|
|
|
// SharedPreferences sharedPref = new SharedPreferences();
|
|
|
|
@ -47,6 +52,8 @@ const DASHBOARD = 'Services/Patients.svc/REST/PatientDashboard';
|
|
|
|
|
const PROFILE_SETTING = 'Services/Patients.svc/REST/GetPateintInfoForUpdate';
|
|
|
|
|
const SAVE_SETTING = 'Services/Patients.svc/REST/UpdatePateintInfo';
|
|
|
|
|
|
|
|
|
|
const DEACTIVATE_ACCOUNT = 'Services/Patients.svc/REST/PatientAppleActivation_InsertUpdate';
|
|
|
|
|
|
|
|
|
|
class AuthProvider with ChangeNotifier {
|
|
|
|
|
bool isLogin = false;
|
|
|
|
|
bool isLoading = true;
|
|
|
|
@ -468,12 +475,6 @@ class AuthProvider with ChangeNotifier {
|
|
|
|
|
|
|
|
|
|
Future<dynamic> getDashboard() async {
|
|
|
|
|
Map<String, dynamic> request = {};
|
|
|
|
|
// request['VersionID'] = VERSION_ID;
|
|
|
|
|
// request['Channel'] = CHANNEL;
|
|
|
|
|
// request['IPAdress'] = IP_ADDRESS;
|
|
|
|
|
// request['generalid'] = GENERAL_ID;
|
|
|
|
|
// request['LanguageID'] = LANGUAGE_ID;
|
|
|
|
|
// request['DeviceTypeID'] = DeviceTypeID;
|
|
|
|
|
|
|
|
|
|
dynamic localRes;
|
|
|
|
|
try {
|
|
|
|
@ -495,16 +496,14 @@ class AuthProvider with ChangeNotifier {
|
|
|
|
|
dynamic localRes;
|
|
|
|
|
try {
|
|
|
|
|
await new BaseAppClient().post(PROFILE_SETTING, onSuccess: (dynamic response, int statusCode) {
|
|
|
|
|
localRes = response; //CheckActivationCode.fromJson();
|
|
|
|
|
localRes = response;
|
|
|
|
|
}, onFailure: (String error, int statusCode) {
|
|
|
|
|
localRes = error;
|
|
|
|
|
return Future.value(error);
|
|
|
|
|
// throw error;
|
|
|
|
|
}, body: {});
|
|
|
|
|
return Future.value(localRes);
|
|
|
|
|
} catch (error) {
|
|
|
|
|
throw error;
|
|
|
|
|
//return Future.value(error);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -512,16 +511,41 @@ class AuthProvider with ChangeNotifier {
|
|
|
|
|
dynamic localRes;
|
|
|
|
|
try {
|
|
|
|
|
await new BaseAppClient().post(SAVE_SETTING, onSuccess: (dynamic response, int statusCode) {
|
|
|
|
|
localRes = response; //CheckActivationCode.fromJson();
|
|
|
|
|
localRes = response;
|
|
|
|
|
}, onFailure: (String error, int statusCode) {
|
|
|
|
|
localRes = error;
|
|
|
|
|
return Future.value(error);
|
|
|
|
|
// throw error;
|
|
|
|
|
}, body: request);
|
|
|
|
|
return Future.value(localRes);
|
|
|
|
|
} catch (error) {
|
|
|
|
|
throw error;
|
|
|
|
|
//return Future.value(error);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future deactivateAccount(request) async {
|
|
|
|
|
dynamic localRes;
|
|
|
|
|
try {
|
|
|
|
|
await new BaseAppClient().post(DEACTIVATE_ACCOUNT, onSuccess: (dynamic response, int statusCode) {
|
|
|
|
|
localRes = response;
|
|
|
|
|
}, onFailure: (String error, int statusCode) {
|
|
|
|
|
localRes = error;
|
|
|
|
|
return Future.value(error);
|
|
|
|
|
}, body: request);
|
|
|
|
|
logout();
|
|
|
|
|
return Future.value(localRes);
|
|
|
|
|
} catch (error) {
|
|
|
|
|
throw error;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
logout() async {
|
|
|
|
|
await sharedPref.remove(LOGIN_TOKEN_ID);
|
|
|
|
|
await sharedPref.remove(PHARMACY_CUSTOMER_ID);
|
|
|
|
|
await authenticatedUserObject.getUser();
|
|
|
|
|
Provider.of<ProjectViewModel>(AppGlobal.context, listen: false).isLogin = false;
|
|
|
|
|
var model = Provider.of<ToDoCountProviderModel>(AppGlobal.context, listen: false);
|
|
|
|
|
model.setState(0, false, null);
|
|
|
|
|
Navigator.of(AppGlobal.context).pushReplacementNamed(HOME);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|