manageStockCountSystemSession method

Future<List<ManageStockCountSession>> manageStockCountSystemSession(
  1. ICProject icproject,
  2. StockCountSystem stockcountSystem,
  3. String action
)

Implementation

Future<List<stockCount.ManageStockCountSession>> manageStockCountSystemSession(icproject.ICProject icproject, stockCount.StockCountSystem stockcountSystem, String action) async{
  var api = await ExternalApiClassHelper.load('external_api');
  var externalApi = tasks. ExternalApiClass(
    externalWebApiToken: api?.externalWebApiToken ?? "",
    externalWebApiTokenName: api?.externalWebApiTokenName ?? "",
    licenseKey: api?.licenseKey ?? "",
    licenseKeyId: api?.licenseKeyId ?? "",
    employeeId: api?.employeeId ?? "",
  );

  var request = tasks. ManageStockCountSessionRequest(
    externalApiClass: externalApi,
    stockCountSystemId: stockcountSystem.stockCountSystemId,
    icprojectid: icproject.icProjectId,
    action: action,
    manageStockCountSession: tasks. ManageStockCountSession(
      manageStockCountSessionStatus: tasks. ManageStockCountSessionStatus()
    )
  );
  final plainBytes = request.writeToBuffer();
  final result = GrpcEncryptedHelper.encrypt(plainBytes);
  final Uint8List iv = result["iv"]!;
  final Uint8List cipherText = result["ciphertext"]!;
  var response = await  taskServiceClient.manageStockCountSystemSession( tasks.EncryptedMessage(iv: iv,ciphertext: cipherText));
  final decryptedBytes = GrpcEncryptedHelper.decrypted(Uint8List.fromList(response.iv), Uint8List.fromList(response.ciphertext));
  final responses = tasks. ManageStockCountSessionResponse.fromBuffer(decryptedBytes);
  List<stockCount.ManageStockCountSession> stockcount =[];
  if(responses.success){
    if(responses.manageStockCountSession.isNotEmpty){
      for(var s in responses.manageStockCountSession){
        stockcount.add(stockCount.ManageStockCountSession(

            manageStockSessionId: s.manageStockSessionId,
            manageStockCountSessionName: s.manageStockCountSessionName,
            useradd: s.useradd,
            useredit: s.useredit,
            dateadd: s.dateadd,
            dateedit: s.dateedit,
            manageStockCountSessionStatus: stockCount.ManageStockCountSessionStatus(
                s.manageStockCountSessionStatus.manageStockCountSessionStatusId,
                s.manageStockCountSessionStatus.statusName
            )
        ));

      }
    }

    return stockcount;
  }

  return [];
}