You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
car_common_app/lib/models/services/service_model.dart

102 lines
4.2 KiB
Dart

import 'package:mc_common_app/models/services/item_model.dart';
class ServiceModel {
final int? serviceProviderServiceId;
final dynamic providerServiceDescription;
final int? categoryId;
final String? categoryName;
final int? serviceId;
final String? serviceDescription;
final String? serviceDescriptionN;
final int? serviceStatus;
final dynamic statusText;
final bool? isAllowAppointment;
final bool? isAllowAppointmentHome;
final int? customerLocationRange;
final String? rangePricePerKm;
final int? itemsCount;
List<ItemData>? serviceItems;
bool isExpandedOrSelected;
int providerServiceId;
String providerServiceName;
bool isHomeSelected;
String homeLocation;
double currentTotalServicePrice;
ServiceModel({
this.serviceProviderServiceId,
this.providerServiceDescription,
this.categoryId,
this.categoryName,
this.serviceId,
this.serviceDescription,
this.serviceDescriptionN,
this.serviceStatus,
this.statusText,
this.isAllowAppointment,
this.isAllowAppointmentHome,
this.customerLocationRange,
this.rangePricePerKm,
this.itemsCount,
this.serviceItems,
this.isHomeSelected = false,
this.homeLocation = "",
this.currentTotalServicePrice = 0.0,
required this.isExpandedOrSelected,
required this.providerServiceId,
required this.providerServiceName,
});
factory ServiceModel.fromJson(Map<String, dynamic> json, {bool isForAppointment = false}) => ServiceModel(
serviceProviderServiceId: json["serviceProviderServiceID"],
providerServiceDescription: json["providerServiceDescription"],
categoryId: json["categoryID"],
categoryName: json["categoryName"],
serviceId: json["serviceID"],
serviceDescription: json["serviceDescription"] ?? json["serviceName"],
serviceDescriptionN: json["serviceDescriptionN"] ?? json["serviceNameN"],
serviceStatus: json["serviceStatus"],
statusText: json["statusText"],
isAllowAppointment: json["isAllowAppointment"],
isAllowAppointmentHome: json["isAllowAppointmentHome"],
customerLocationRange: json["customerLocationRange"],
rangePricePerKm: json["rangePricePerKm"].toString(),
itemsCount: json["itemsCount"],
serviceItems: isForAppointment
? json["serviceItemList"] == null
? []
: List<ItemData>.from(json["serviceItemList"]!.map((x) => ItemData.fromJson(x)))
: json["branchServiceItems"] == null
? []
: List<ItemData>.from(json["branchServiceItems"]!.map((x) => ItemData.fromJson(x))),
isExpandedOrSelected: false,
providerServiceId: 0,
providerServiceName: "",
isHomeSelected: false,
homeLocation: "",
);
Map<String, dynamic> toJson() => {
"serviceProviderServiceID": serviceProviderServiceId,
"providerServiceDescription": providerServiceDescription,
"categoryID": categoryId,
"categoryName": categoryName,
"serviceID": serviceId,
"serviceDescription": serviceDescription,
"serviceDescriptionN": serviceDescriptionN,
"serviceStatus": serviceStatus,
"statusText": statusText,
"isAllowAppointment": isAllowAppointment,
"isAllowAppointmentHome": isAllowAppointmentHome,
"customerLocationRange": customerLocationRange,
"rangePricePerKm": rangePricePerKm,
"itemsCount": itemsCount,
"branchServiceItems": serviceItems == null ? [] : List<dynamic>.from(serviceItems!.map((x) => x.toJson())),
};
@override
String toString() {
return 'ServiceModel{serviceProviderServiceId: $serviceProviderServiceId, providerServiceDescription: $providerServiceDescription, categoryId: $categoryId, categoryName: $categoryName, serviceId: $serviceId, serviceDescription: $serviceDescription, serviceDescriptionN: $serviceDescriptionN, serviceStatus: $serviceStatus, statusText: $statusText, isAllowAppointment: $isAllowAppointment, isAllowAppointmentHome: $isAllowAppointmentHome, customerLocationRange: $customerLocationRange, rangePricePerKm: $rangePricePerKm, itemsCount: $itemsCount, serviceItems: $serviceItems, isExpandedOrSelected: $isExpandedOrSelected}';
}
}