tablet-app/lib/Models/agenda.dart
2024-01-26 15:52:25 +01:00

125 lines
2.9 KiB
Dart

import 'dart:convert';
class Agenda {
List<EventAgenda> events;
Agenda({required this.events});
factory Agenda.fromJson(String jsonString) {
final List<dynamic> jsonList = json.decode(jsonString);
List<EventAgenda> events = [];
for (var eventData in jsonList) {
events.add(EventAgenda.fromJson(eventData));
}
return Agenda(events: events);
}
}
class EventAgenda {
String name;
String description;
String type;
DateTime dateAdded;
DateTime dateFrom;
DateTime dateTo;
String dateHour;
EventAddress address;
String website;
String phone;
String idVideoYoutube;
String email;
String image;
EventAgenda({
required this.name,
required this.description,
required this.type,
required this.dateAdded,
required this.dateFrom,
required this.dateTo,
required this.dateHour,
required this.address,
required this.website,
required this.phone,
required this.idVideoYoutube,
required this.email,
required this.image,
});
factory EventAgenda.fromJson(Map<String, dynamic> json) {
return EventAgenda(
name: json['name'],
description: json['description'],
type: json['type'],
dateAdded: DateTime.parse(json['date_added']),
dateFrom: DateTime.parse(json['date_from']),
dateTo: DateTime.parse(json['date_to']),
dateHour: json['date_hour'],
address: EventAddress.fromJson(json['address']),
website: json['website'],
phone: json['phone'],
idVideoYoutube: json['id_video_youtube'],
email: json['email'],
image: json['image'],
);
}
}
class EventAddress {
String address;
double lat;
double lng;
int zoom;
String placeId;
String name;
String streetNumber;
String streetName;
String streetNameShort;
String city;
String state;
String stateShort;
String postCode;
String country;
String countryShort;
EventAddress({
required this.address,
required this.lat,
required this.lng,
required this.zoom,
required this.placeId,
required this.name,
required this.streetNumber,
required this.streetName,
required this.streetNameShort,
required this.city,
required this.state,
required this.stateShort,
required this.postCode,
required this.country,
required this.countryShort,
});
factory EventAddress.fromJson(Map<String, dynamic> json) {
return EventAddress(
address: json['address'],
lat: json['lat'],
lng: json['lng'],
zoom: json['zoom'],
placeId: json['place_id'],
name: json['name'],
streetNumber: json['street_number'],
streetName: json['street_name'],
streetNameShort: json['street_name_short'],
city: json['city'],
state: json['state'],
stateShort: json['state_short'],
postCode: json['post_code'],
country: json['country'],
countryShort: json['country_short'],
);
}
}