deleteProduct function

Future<String?> deleteProduct(
  1. ProductData val
)

////////////////////////////////////////////////////////////////////////////// / EDIT /// ////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////

Implementation

/*
currentProduct

deleteProduct
saveProduct
addImageToGallery
deleteImageFromGallery
productSetDescTitle
productSetDesc
productSetName
price
  productSetNamePrice
  productSetPriceImageData
  productSetPrice
  productSetDiscPrice
  productGetPriceUnitCombo
  productSetPriceUnitCombo
Addon
  productAddAddon
  selectAddon
  deleteAddon
 */
/////////////////////////////////////////////////////////////////////////////////

Future<String?> deleteProduct(ProductData val) async {
  try{
    await FirebaseFirestore.instance.collection("service").doc(val.id).set({
      "delete": true,
      "timeModify": DateTime.now().toUtc(),
    }, SetOptions(merge:true));
    await FirebaseFirestore.instance.collection("settings").doc("main")
        .set({"service_count": FieldValue.increment(-1)}, SetOptions(merge:true));
    // services.remove(val);
  }catch(ex){
    return "deleteProduct " + ex.toString();
  }
  // parent.notify();
  return null;
}