import 'package:test_sa/modules/asset_delivery_module/models/cost_center_model.dart';

class CostCenterSerialNoFormModel {
  List<CostCenterModel>? costCenters;
  List<SerialNoModel>? serialNos;

  CostCenterSerialNoFormModel({
    this.costCenters,
    this.serialNos,
  });

  // From JSON
  CostCenterSerialNoFormModel.fromJson(Map<String, dynamic> json) {
    if (json['costCenters'] != null) {
      costCenters = List<CostCenterModel>.from((json['costCenters'] as List).map((e) => CostCenterModel.fromJson(e)));
    }

    if (json['serialNos'] != null) {
      serialNos = List<SerialNoModel>.from((json['serialNos'] as List).map((e) => SerialNoModel.fromJson(e)));
    }
  }

  // To JSON
  Map<String, dynamic> toJson() {
    return {
      'costCenters': costCenters?.map((e) => e.toJson()).toList() ?? [],
      'serialNos': serialNos?.map((e) => e.toJson()).toList() ?? [],
    };
  }
}


class SerialNoModel {
  int? id;
  String? serialNo;
  SerialNoModel({
    this.id,
    this.serialNo,
  });
  SerialNoModel.fromJson(Map<String, dynamic> json) {
    id = json['id'] ?? json['costCenterId'];
    serialNo = json['serialNo'];
  }
  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = {};
    data['id'] = id ?? 0;
    data['serialNo'] = serialNo;
    return data;
  }
}



