setDeviceImplementedRecommendation method

Future<bool> setDeviceImplementedRecommendation({
  1. required Recommendations recommendation,
})

set device ImplementedRecommendation @param recommendationId as string @return bool

Implementation

Future<bool> setDeviceImplementedRecommendation(
    {required Recommendations recommendation}) async {
  Device currentDevice = await getDeviceInfo;

  List<Recommendations> implementedRecommendations = [];

  try {
    _node = await _storageController
        .get(":Devices:${currentDevice.deviceId}:gi:data:GeigerScoreDevice");
    implementedRecommendations.add(recommendation);

    NodeValue implementedRecom = NodeValueImpl("implementedRecommendations",
        Recommendations.convertToJson(implementedRecommendations));
    await _node!.addOrUpdateValue(implementedRecom);

    await _storageController.update(_node!);
    return true;
  } catch (e) {
    log("failed to addOrUpdate implementedRecommendations NodeValue");
    return false;
  }
}