import 'dart:collection'; import 'package:flutter_form_bloc/flutter_form_bloc.dart'; import 'customer_property.dart'; class Customer { String name; String email; String firstname; String sex; int age; String active; int customerId; String password; int birthYear; String goal; String fitnessLevel; String bodyType; int admin; int trainer; int dataPolicyAllowed; String firebaseUid; DateTime dateAdd; DateTime dateChange; LinkedHashMap properties = LinkedHashMap(); Customer( {this.customerId, this.name, this.firstname, this.email, this.sex, this.age, this.active, this.password, this.birthYear, this.bodyType, this.fitnessLevel, this.goal, this.admin, this.trainer, this.dataPolicyAllowed, this.firebaseUid, this.dateAdd, this.dateChange}); Customer.fromJson(Map json) { this.customerId = json['customerId']; this.name = json['name']; this.firstname = json['firstname']; this.email = json['email']; this.sex = json['sex']; this.age = json['age']; this.active = json['active']; this.birthYear = json['birthYear']; this.bodyType = json['bodyType']; this.fitnessLevel = json['fitnessLevel']; this.goal = json['goal']; this.admin = json['admin']; this.trainer = json['trainer']; this.firebaseUid = json['firebaseUid']; this.dateAdd = json['dateAdd'] == null ? DateTime.parse("0000-00-00") : DateTime.parse(json['dateAdd']); this.dateChange = json['dateChange'] == null ? DateTime.parse("0000-00-00") : DateTime.parse(json['dateChange']); } Map toJson() => { "name": name, "firstname": firstname, "email": email, "age": age, "sex": sex, "active": 'Y', "password": password, "birthYear": birthYear, "bodyType": bodyType, "fitnessLevel": fitnessLevel, "goal": goal, "admin": admin, "trainer": trainer, "dataPolicyAllowed": dataPolicyAllowed, "dateAdd": DateFormat('yyyy-MM-dd HH:mm:ss').format(this.dateAdd), "dateChange": DateFormat('yyyy-MM-dd HH:mm:ss').format(this.dateChange), }; double getProperty(String propertyName) { if (this.properties[propertyName] == null) { return 0; } else { return this.properties[propertyName].propertyValue; } } setProperty(String propertyName, double value) { this.properties[propertyName].propertyValue = value; } }