66 lines
2.0 KiB
Dart
66 lines
2.0 KiB
Dart
import 'package:fotodocumentation/utils/date_time_utils.dart';
|
|
|
|
class CustomerListDto {
|
|
final int id;
|
|
final String name;
|
|
final String customerNumber;
|
|
final DateTime? lastUpdateDate;
|
|
|
|
CustomerListDto({required this.id, required this.name, required this.customerNumber, this.lastUpdateDate});
|
|
|
|
/// Create from JSON response
|
|
factory CustomerListDto.fromJson(Map<String, dynamic> json) {
|
|
return CustomerListDto(
|
|
id: json['id'] as int,
|
|
name: json['name'] as String,
|
|
customerNumber: json['customerNumber'] as String,
|
|
lastUpdateDate: DateTimeUtils.toDateTime(json['lastUpdateDate']),
|
|
);
|
|
}
|
|
}
|
|
|
|
class CustomerDto {
|
|
final int id;
|
|
final String name;
|
|
final String customerNumber;
|
|
final List<PictureDto> pictures;
|
|
|
|
CustomerDto({required this.id, required this.name, required this.customerNumber, required this.pictures});
|
|
|
|
/// Create from JSON response
|
|
factory CustomerDto.fromJson(Map<String, dynamic> json) {
|
|
return CustomerDto(
|
|
id: json['id'] as int,
|
|
name: json['name'] as String,
|
|
customerNumber: json['customerNumber'] as String,
|
|
pictures: List<PictureDto>.from(json["pictures"].map((x) => PictureDto.fromJson(x))),
|
|
);
|
|
}
|
|
}
|
|
|
|
class PictureDto {
|
|
final int id;
|
|
final String? comment;
|
|
final String? category;
|
|
final String image;
|
|
final DateTime pictureDate;
|
|
final String? username;
|
|
final CustomerListDto customerListDto;
|
|
|
|
PictureDto(
|
|
{required this.id, required this.comment, required this.category, required this.image, required this.pictureDate, required this.username, required this.customerListDto});
|
|
|
|
/// Create from JSON response
|
|
factory PictureDto.fromJson(Map<String, dynamic> json) {
|
|
return PictureDto(
|
|
id: json['id'] as int,
|
|
comment: json['comment'] as String?,
|
|
category: json['category'] as String?,
|
|
image: json['image'] as String,
|
|
pictureDate: DateTimeUtils.toDateTime(json['pictureDate']) ?? DateTime.now(),
|
|
username: json['username'] as String?,
|
|
customerListDto: CustomerListDto.fromJson(json['customer']),
|
|
);
|
|
}
|
|
}
|