insertPeriodLog method

Future<int> insertPeriodLog(
  1. List<DateTime> selectedPeriodsDate
)

insert user's period data on userId and log date

Implementation

Future<int> insertPeriodLog(List<DateTime> selectedPeriodsDate) async {
  //printLogs("selectedPeriodsDate ${selectedPeriodsDate.toString()}");
  final mInstance = MenstrualCycleWidget.instance!;
  String customerId = mInstance.getCustomerId();
  Database? db = await instance.database;

  for (int i = 0; i < selectedPeriodsDate.length; i++) {
    Map<String, dynamic> data = {
      columnCustomerId: customerId,
      columnPeriodEncryptDate: Encryption.instance
          .encrypt(CalenderDateUtils.dateDayFormat(selectedPeriodsDate[i])),
    };

    ///insert a new periods log
    await db!.insert(tableUserPeriodsLogsData, data);
  }
  //printLogs("Insert Period Data");
  return 0;
}