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..");
  try {
    await ApiClient(baseUrl: ApiConstant.posBL)
        .deleteProductById(
            cartId: cartId,
            productId: productId,
            xRoles: storage.read("XUSER_ID"),
            xUserId: storage.read("XUSER_ID"))
        .then((response) async {
      cart.CartModel model = response;
      if (model.status == "POS200") {
        // deleteProduct(data);
        cartId = model.data!.cartId!;
        discountList.value = model.data!.cartDiscountsList!;
        Helper.close();
        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, data.productCode);
        }
      } else {
        Helper.close();
        if (model.errors != null) {
          Helper.messageDialog(
              Get.context!,
              model.errors![0].code ?? "Try again!!",
              model.errors![0].localeMessage ?? "Something went wrong");
        }
      }
    }).catchError((error) {
      print(error.toString());
      Helper.close();
      MainController mainController = Get.put(MainController());
      mainController.showErrorPopup();
    });
  } catch (err, stacktrace) {
    Helper.close();
    log(err.toString());
    print(stacktrace);
  }
}