Début page calendrier
This commit is contained in:
		
							
								
								
									
										62
									
								
								em2rp/lib/models/event_model.dart
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										62
									
								
								em2rp/lib/models/event_model.dart
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,62 @@ | ||||
| import 'package:cloud_firestore/cloud_firestore.dart'; | ||||
| import 'package:latlong2/latlong.dart'; | ||||
|  | ||||
| class EventModel { | ||||
|   final String id; | ||||
|   final String name; | ||||
|   final String description; | ||||
|   final DateTime startDateTime; | ||||
|   final DateTime endDateTime; | ||||
|   final double price; | ||||
|   final int installationTime; | ||||
|   final int disassemblyTime; | ||||
|   final String eventTypeId; | ||||
|   final String customerId; | ||||
|   final LatLng address; | ||||
|  | ||||
|   EventModel({ | ||||
|     required this.id, | ||||
|     required this.name, | ||||
|     required this.description, | ||||
|     required this.startDateTime, | ||||
|     required this.endDateTime, | ||||
|     required this.price, | ||||
|     required this.installationTime, | ||||
|     required this.disassemblyTime, | ||||
|     required this.eventTypeId, | ||||
|     required this.customerId, | ||||
|     required this.address, | ||||
|   }); | ||||
|  | ||||
|   factory EventModel.fromMap(Map<String, dynamic> map, String id) { | ||||
|     final GeoPoint geoPoint = map['address'] as GeoPoint; | ||||
|     return EventModel( | ||||
|       id: id, | ||||
|       name: map['name'] ?? '', | ||||
|       description: map['description'] ?? '', | ||||
|       startDateTime: (map['startDateTime'] as Timestamp).toDate(), | ||||
|       endDateTime: (map['endDateTime'] as Timestamp).toDate(), | ||||
|       price: (map['price'] ?? 0.0).toDouble(), | ||||
|       installationTime: map['installationTime'] ?? 0, | ||||
|       disassemblyTime: map['disassemblyTime'] ?? 0, | ||||
|       eventTypeId: map['eventType'] ?? '', | ||||
|       customerId: map['customer'] ?? '', | ||||
|       address: LatLng(geoPoint.latitude, geoPoint.longitude), | ||||
|     ); | ||||
|   } | ||||
|  | ||||
|   Map<String, dynamic> toMap() { | ||||
|     return { | ||||
|       'name': name, | ||||
|       'description': description, | ||||
|       'startDateTime': Timestamp.fromDate(startDateTime), | ||||
|       'endDateTime': Timestamp.fromDate(endDateTime), | ||||
|       'price': price, | ||||
|       'installationTime': installationTime, | ||||
|       'disassemblyTime': disassemblyTime, | ||||
|       'eventType': eventTypeId, | ||||
|       'customer': customerId, | ||||
|       'address': GeoPoint(address.latitude, address.longitude), | ||||
|     }; | ||||
|   } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user