import 'package:farm_tpf/custom_model/SuppliesUsing.dart';
import 'package:farm_tpf/custom_model/action_form/ActionUIField.dart';

class RequestActivity {
  int? id;
  int? tbActivityTypeId;
  int? tbCropId;
  num? totalCost;
  String? executeDate;
  String? externalTable;
  String? description;
  String? media;
  List<TbObjectUpdateDTO>? tbObjectUpdateDTOList;
  List<SuppliesUsing>? tbSuppliesUsingDetailsDTOs;
  List<TbNurseryDetailsDTO>? tbNurseryDetailsDTOList;
  List<String>? deletedImages;

  RequestActivity(
      {this.id,
      this.tbActivityTypeId,
      this.tbCropId,
      this.totalCost,
      this.executeDate,
      this.externalTable,
      this.description,
      this.media,
      this.tbObjectUpdateDTOList,
      this.tbSuppliesUsingDetailsDTOs,
      this.tbNurseryDetailsDTOList,
      this.deletedImages});

  RequestActivity.fromJson(Map<String, dynamic> json) {
    id = json['id'];
    tbActivityTypeId = json['tbActivityTypeId'];
    tbCropId = json['tbCropId'];
    totalCost = json['totalCost'];
    executeDate = json['executeDate'];
    externalTable = json['externalTable'];
    description = json['description'];
    media = json['media'];
    if (json['tbObjectUpdateDTOList'] != null) {
      tbObjectUpdateDTOList = <TbObjectUpdateDTO>[];
      json['tbObjectUpdateDTOList'].forEach((v) {
        tbObjectUpdateDTOList?.add(new TbObjectUpdateDTO.fromJson(v));
      });
    }
    if (json['tbSuppliesUsingDetailsDTOs'] != null) {
      tbSuppliesUsingDetailsDTOs = <SuppliesUsing>[];
      json['tbSuppliesUsingDetailsDTOs'].forEach((v) {
        tbSuppliesUsingDetailsDTOs?.add(new SuppliesUsing.fromJson(v));
      });
    }
    if (json['tbNurseryDetailsDTOList'] != null) {
      tbNurseryDetailsDTOList = <TbNurseryDetailsDTO>[];
      json['tbNurseryDetailsDTOList'].forEach((v) {
        tbNurseryDetailsDTOList?.add(new TbNurseryDetailsDTO.fromJson(v));
      });
    }
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['id'] = this.id;
    data['tbActivityTypeId'] = this.tbActivityTypeId;
    data['tbCropId'] = this.tbCropId;
    data['totalCost'] = this.totalCost;
    data['executeDate'] = this.executeDate;
    data['externalTable'] = this.externalTable;
    data['description'] = this.description;
    data['media'] = this.media;
    if (this.tbObjectUpdateDTOList != null) {
      data['tbObjectUpdateDTOList'] = this.tbObjectUpdateDTOList?.map((v) => v.toJson()).toList();
    }
    if (this.tbSuppliesUsingDetailsDTOs != null) {
      data['tbSuppliesUsingDetailsDTOs'] = this.tbSuppliesUsingDetailsDTOs?.map((v) => v.toJson()).toList();
    }
    if (this.tbNurseryDetailsDTOList != null) {
      data['tbNurseryDetailsDTOList'] = this.tbNurseryDetailsDTOList?.map((v) => v.toJson()).toList();
    }
    data['deletedImages'] = this.deletedImages;
    return data;
  }
}

class TbObjectUpdateDTO {
  int? tbObjectParameterId;
  String? index;
  int? id;
  ActionUIField? tbObjectParameterDTO;

  TbObjectUpdateDTO({this.tbObjectParameterId, this.index, this.id, this.tbObjectParameterDTO});

  TbObjectUpdateDTO.fromJson(Map<String, dynamic> json) {
    tbObjectParameterId = json['tbObjectParameterId'];
    index = json['index'];
    id = json['id'];
    tbObjectParameterDTO = json['tbObjectParameterDTO'] != null ? new ActionUIField.fromJson(json['tbObjectParameterDTO']) : null;
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['tbObjectParameterId'] = this.tbObjectParameterId;
    data['index'] = this.index;
    data['id'] = this.id;
    if (this.tbObjectParameterDTO != null) {
      data['tbObjectParameterDTO'] = this.tbObjectParameterDTO?.toJson();
    }
    return data;
  }
}

class TbNurseryDetailsDTO {
  int? id;
  String? workerName;
  String? trayNumber;

  TbNurseryDetailsDTO({this.workerName, this.trayNumber});

  TbNurseryDetailsDTO.fromJson(Map<String, dynamic> json) {
    id = json['id'];
    workerName = json['workerName'];
    trayNumber = json['trayNumber'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['id'] = this.id;
    data['workerName'] = this.workerName;
    data['trayNumber'] = this.trayNumber;
    return data;
  }
}
