|
|
|
|
@ -6,6 +6,7 @@ import 'package:diplomaticquarterapp/models/pharmacy/locationModel.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/models/pharmacy/productDetailModel.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/models/pharmacy/specification.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/uitl/app_toast.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/uitl/utils.dart';
|
|
|
|
|
|
|
|
|
|
class ProductDetailService extends BaseService {
|
|
|
|
|
@ -91,7 +92,7 @@ class ProductDetailService extends BaseService {
|
|
|
|
|
}, body: request);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<Map> addToCart(quantity, itemID) async {
|
|
|
|
|
Future<Map> addToCart(quantity, itemID, context) async {
|
|
|
|
|
var customerId = await sharedPref.getString(PHARMACY_CUSTOMER_ID);
|
|
|
|
|
hasError = false;
|
|
|
|
|
Map<String, dynamic> request;
|
|
|
|
|
@ -106,7 +107,9 @@ class ProductDetailService extends BaseService {
|
|
|
|
|
response['shopping_carts'].forEach((item) {
|
|
|
|
|
_addToCartModel.add(Wishlist.fromJson(item));
|
|
|
|
|
});
|
|
|
|
|
AppToast.showSuccessToast(message: 'You have added a product to the cart');
|
|
|
|
|
AppToast.showSuccessToast(message: TranslationBase.of(context).addToCartMsg
|
|
|
|
|
// 'You have added a product to the cart'
|
|
|
|
|
);
|
|
|
|
|
localRes = response;
|
|
|
|
|
}, onFailure: (String error, int statusCode) {
|
|
|
|
|
hasError = true;
|
|
|
|
|
@ -117,10 +120,12 @@ class ProductDetailService extends BaseService {
|
|
|
|
|
return Future.value(localRes);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future notifyMe(customerId, itemID) async {
|
|
|
|
|
Future notifyMe(customerId, itemID, context) async {
|
|
|
|
|
hasError = false;
|
|
|
|
|
await baseAppClient.getPharmacy(SUBSCRIBE_PRODUCT + "SinceId=$customerId&ProductId=$itemID", onSuccess: (dynamic response, int statusCode) {
|
|
|
|
|
AppToast.showSuccessToast(message: 'You will be notified when product available');
|
|
|
|
|
AppToast.showSuccessToast(message: TranslationBase.of(context).notifyMeMsg
|
|
|
|
|
//'You will be notified when product available'
|
|
|
|
|
);
|
|
|
|
|
}, onFailure: (String error, int statusCode) {
|
|
|
|
|
hasError = true;
|
|
|
|
|
super.error = error;
|
|
|
|
|
@ -128,7 +133,7 @@ class ProductDetailService extends BaseService {
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future addToWishlist(itemID) async {
|
|
|
|
|
Future addToWishlist(itemID, context) async {
|
|
|
|
|
var customerId = await sharedPref.getString(PHARMACY_CUSTOMER_ID);
|
|
|
|
|
hasError = false;
|
|
|
|
|
Map<String, dynamic> request;
|
|
|
|
|
@ -141,7 +146,9 @@ class ProductDetailService extends BaseService {
|
|
|
|
|
response['shopping_carts'].forEach((item) {
|
|
|
|
|
_wishListProducts.add(Wishlist.fromJson(item));
|
|
|
|
|
});
|
|
|
|
|
AppToast.showSuccessToast(message: 'You have added a product to the Wishlist');
|
|
|
|
|
AppToast.showSuccessToast(message: TranslationBase.of(context).addToWishlistMsg
|
|
|
|
|
// 'You have added a product to the Wishlist'
|
|
|
|
|
);
|
|
|
|
|
}, onFailure: (String error, int statusCode) {
|
|
|
|
|
hasError = true;
|
|
|
|
|
super.error = error;
|
|
|
|
|
@ -163,7 +170,7 @@ class ProductDetailService extends BaseService {
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future deleteItemFromWishlist(itemID) async {
|
|
|
|
|
Future deleteItemFromWishlist(itemID, context) async {
|
|
|
|
|
var customerId = await sharedPref.getString(PHARMACY_CUSTOMER_ID);
|
|
|
|
|
hasError = false;
|
|
|
|
|
await baseAppClient.getPharmacy(DELETE_WISHLIST + customerId + "+&product_id=" + itemID + "&cart_type=Wishlist", onSuccess: (dynamic response, int statusCode) {
|
|
|
|
|
@ -171,7 +178,9 @@ class ProductDetailService extends BaseService {
|
|
|
|
|
response['shopping_carts'].forEach((item) {
|
|
|
|
|
_wishListProducts.add(Wishlist.fromJson(item));
|
|
|
|
|
});
|
|
|
|
|
AppToast.showSuccessToast(message: 'You have removed a product from the Wishlist');
|
|
|
|
|
AppToast.showSuccessToast(message: TranslationBase.of(context).removeFromWishlistMsg
|
|
|
|
|
// 'You have removed a product from the Wishlist'
|
|
|
|
|
);
|
|
|
|
|
}, onFailure: (String error, int statusCode) {
|
|
|
|
|
hasError = true;
|
|
|
|
|
super.error = error;
|
|
|
|
|
|