save method

Future<bool> save()

Implementation

Future<bool> save() async {
  final UTerminalResponse? t = editing;
  if (t == null && (brand == null || broker == null)) {
    UToast.error(message: U.s.required);
    return false;
  }
  return await send(
        t == null
            ? UServices.terminal.create(
                p: UTerminalCreateParams(
                  tags: <int>[TagTerminal.notAssigned.number],
                  serial: serialController.text.trim(),
                  simCardNumber: simCardNumberController.text.nullIfEmpty(),
                  simCardSerial: simCardSerialController.text.nullIfEmpty(),
                  imei: imeiController.text.nullIfEmpty(),
                  terminalBrandId: brand!.id,
                  terminalBrokerId: broker!.id,
                ),
              )
            : UServices.terminal.update(
                p: UTerminalUpdateParams(
                  id: t.id,
                  serial: serialController.text.nullIfEmpty(),
                  simCardNumber: simCardNumberController.text.nullIfEmpty(),
                  simCardSerial: simCardSerialController.text.nullIfEmpty(),
                  imei: imeiController.text.nullIfEmpty(),
                  terminalId: terminalIdController.text.nullIfEmpty(),
                  terminalBrandId: brand?.id,
                  terminalBrokerId: broker?.id,
                ),
              ),
        read,
      ) !=
      null;
}