import 'dart:convert';

import 'package:flutter/cupertino.dart';

class ModelOrder {
  final int id;
  final double value;
  final String text_artist;
  final String text_music;
  final String person_customer_name;
  final int person_customer_id;
  final String note;
  final String status;
  final int id_event;
  final int id_person_artist;
  final int id_event_artist;

  ModelOrder({
    @required this.id,
    @required this.value,
    @required this.text_artist,
    @required this.text_music,
    this.person_customer_name,
    @required this.person_customer_id,
    @required this.note,
    @required this.status,
     this.id_event,
    this.id_person_artist,
     this.id_event_artist,
  });

  factory ModelOrder.fromJson(Map<String, dynamic> json) {
    return ModelOrder(
      id: json['id'],
      value: double.tryParse(json['value'].toString()),
      text_artist: json['text_artist'],
      text_music: json['text_music'],
      person_customer_name: json['id_person_customer']['name'],
      person_customer_id: json['id_person_customer']['id'],
      note: json['note'],
      status: json['status'],
    );
  }

  String toJson() => json.encode({
    'id' :  this.id,
    'id_person_customer': this.person_customer_id,
    'id_event': this.id_event,
    'id_person_artist': this.id_person_artist,
    'id_event_artist': this.id_event_artist,
    'text_artist': this.text_artist,
    'text_music': this.text_music,
    'note': this.note,
    'value': this.value,
    'status': this.status
  });

  String toJsonNew() => json.encode({
        'id_person_customer': this.person_customer_id,
        'id_event': this.id_event,
        'id_person_artist': this.id_person_artist,
        'id_event_artist': this.id_event_artist,
        'text_artist': this.text_artist,
        'text_music': this.text_music,
        'note': this.note,
        'value': this.value,
        'status': this.status
      });

  Map<String, dynamic> toJson2() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['id'] = this.id;
    data['id_person_customer'] = this.person_customer_id;
    data['id_event'] = this.id_event;
    data['id_person_artist'] = this.id_person_artist;
    data['id_event_artist'] = this.id_event_artist;
    data['text_artist'] = this.text_artist;
    data['text_music'] = this.text_music;
    data['note'] = this.note;
    data['value'] = this.value;
    data['status'] = this.status;
    return data;
  }

  Map<String, dynamic> toJsonNew2() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['id_person_customer'] = this.person_customer_id;
    data['id_event'] = this.id_event;
    data['id_person_artist'] = this.id_person_artist;
    data['id_event_artist'] = this.id_event_artist;
    data['text_artist'] = this.text_artist;
    data['text_music'] = this.text_music;
    data['note'] = this.note;
    data['value'] = this.value;
    data['status'] = this.status;
    return data;
  }
}
