callDeleteProductByIdApi method

Future<void> callDeleteProductByIdApi(
  1. String productId,
  2. ProductContentModel data
)

Implementation

Future<void> callDeleteProductByIdApi(
    String productId, ProductContentModel data) async {
  BuildContext context = Get.context!;
  Helper.progressDialog(context, "Please wait..");

  await ApiClient(baseUrl: ApiConstant.posBL)
      .deleteProductById(
          cartId: cartId,
          productId: productId,
          xRoles: storage.read("XUSER_ID"),
          xUserId: storage.read("XUSER_ID"))
      .then((response) async {
    Get.back();
    cart.CartModel model = response;
    if (model.status == "POS200") {
      // deleteProduct(data);
      cartId = model.data!.cartId!;
      discountList.value = model.data!.cartDiscountsList!;
      if (currentScan == ScanType.spotSellThru) {
        updateSpotSellThruOrder(model);
      } else if (currentScan == ScanType.sellThru) {
        updateSellThruOrder(model);
      } else if (currentScan == ScanType.collectStock) {
        totalRetailPrice = model.data!.totalRetailPrice as double;
        await updateCollectStock(model, null, null, null);
      }
    } else {
      if (model.errors != null) {
        Helper.messageDialog(
            Get.context!,
            model.errors![0].code ?? "Try again!!",
            model.errors![0].localeMessage ?? "Something went wrong");
      }
    }
  }, onError: (error) {
    print(error.toString());
    Get.back();
    Helper.messageDialog(Get.context!, "Try Again!!", error.toString());
  });
}