asset by oracle code api added, departments lookup added.
							parent
							
								
									56328b81b4
								
							
						
					
					
						commit
						76acdddabc
					
				| @ -0,0 +1,27 @@ | ||||
| class AssetNDAutoCompleteByDynamicCodesModel { | ||||
|   int? id; | ||||
|   String? assetName; | ||||
|   int? codeTypeId; | ||||
|   String? codeValue; | ||||
|   String? displayName; | ||||
| 
 | ||||
|   AssetNDAutoCompleteByDynamicCodesModel({this.id, this.assetName, this.codeTypeId, this.codeValue, this.displayName}); | ||||
| 
 | ||||
|   AssetNDAutoCompleteByDynamicCodesModel.fromJson(Map<String, dynamic> json) { | ||||
|     id = json['id']; | ||||
|     assetName = json['assetName']; | ||||
|     codeTypeId = json['codeTypeId']; | ||||
|     codeValue = json['codeValue']; | ||||
|     displayName = json['displayName']; | ||||
|   } | ||||
| 
 | ||||
|   Map<String, dynamic> toJson() { | ||||
|     final Map<String, dynamic> data = new Map<String, dynamic>(); | ||||
|     data['id'] = this.id; | ||||
|     data['assetName'] = this.assetName; | ||||
|     data['codeTypeId'] = this.codeTypeId; | ||||
|     data['codeValue'] = this.codeValue; | ||||
|     data['displayName'] = this.displayName; | ||||
|     return data; | ||||
|   } | ||||
| } | ||||
| @ -0,0 +1,101 @@ | ||||
| import 'package:test_sa/models/new_models/room_model.dart'; | ||||
| 
 | ||||
| import '../base.dart'; | ||||
| 
 | ||||
| class TrafDepartment extends Base { | ||||
|   TrafDepartment({ | ||||
|     this.departmentName, this.departmentCode, this.ntCode, this.costCenterNumber, this.costCenterName, this.name, this.id, this.createdBy, this.createdDate, this.modifiedBy, this.modifiedDate | ||||
|   }) : super(identifier: id?.toString() ?? '', name: departmentName); // Handle potential null id | ||||
| 
 | ||||
|   TrafDepartment.fromJson(Map<String, dynamic> json) { | ||||
|     departmentName = json['departmentName'] ?? json['name']; | ||||
|     departmentCode = json['departmentCode']; | ||||
|     ntCode = json['ntCode']; | ||||
|     costCenterNumber = json['costCenterNumber']; | ||||
|     costCenterName = json['costCenterName']; | ||||
|     name = json['name']; | ||||
|     id = json['id']; | ||||
|     createdBy = json['createdBy']; | ||||
|     createdDate = json['createdDate']; | ||||
|     modifiedBy = json['modifiedBy']; | ||||
|     modifiedDate = json['modifiedDate']; | ||||
|   } | ||||
| 
 | ||||
|   num? id; // Now nullable | ||||
|   String? departmentName; // Now nullable | ||||
|   String? departmentCode; // Now nullable | ||||
|   String? ntCode; | ||||
|   String? costCenterNumber; | ||||
|   String? costCenterName; | ||||
|   String? name; | ||||
|   String? createdBy; | ||||
|   String? createdDate; | ||||
|   String? modifiedBy; | ||||
|   String? modifiedDate; | ||||
| 
 | ||||
|   // TrafDepartment copyWith({ | ||||
|   //   num? id, // Parameters are now nullable | ||||
|   //   String? departmentName, | ||||
|   //   String? departmentCode, | ||||
|   //   String? departmentId, | ||||
|   //   String? ntCode, | ||||
|   //   List<Rooms>? rooms, | ||||
|   // }) => | ||||
|   //     TrafDepartment( | ||||
|   //       id: id ?? this.id, | ||||
|   //       departmentName: departmentName ?? this.departmentName, | ||||
|   //       departmentCode: departmentCode ?? this.departmentCode, | ||||
|   //       departmentId: departmentId ?? this.departmentId, | ||||
|   //       ntCode: ntCode ?? this.ntCode, | ||||
|   //       rooms: rooms ?? this.rooms, | ||||
|   //     ); | ||||
| 
 | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| // class TrafDepartment extends Base { | ||||
| //   String? departmentName; | ||||
| //   String? departmentCode; | ||||
| //   Null? ntCode; | ||||
| //   Null? costCenterNumber; | ||||
| //   Null? costCenterName; | ||||
| //   String? name; | ||||
| //   int? id; | ||||
| //   String? createdBy; | ||||
| //   String? createdDate; | ||||
| //   Null? modifiedBy; | ||||
| //   Null? modifiedDate; | ||||
| // | ||||
| //   TrafDepartment( | ||||
| //       {this.departmentName, this.departmentCode, this.ntCode, this.costCenterNumber, this.costCenterName, this.name, this.id, this.createdBy, this.createdDate, this.modifiedBy, this.modifiedDate}); | ||||
| // | ||||
| //   TrafDepartment.fromJson(Map<String, dynamic> json) { | ||||
| //     departmentName = json['departmentName']; | ||||
| //     departmentCode = json['departmentCode']; | ||||
| //     ntCode = json['ntCode']; | ||||
| //     costCenterNumber = json['costCenterNumber']; | ||||
| //     costCenterName = json['costCenterName']; | ||||
| //     name = json['name']; | ||||
| //     id = json['id']; | ||||
| //     createdBy = json['createdBy']; | ||||
| //     createdDate = json['createdDate']; | ||||
| //     modifiedBy = json['modifiedBy']; | ||||
| //     modifiedDate = json['modifiedDate']; | ||||
| //   } | ||||
| // | ||||
| //   Map<String, dynamic> toJson() { | ||||
| //     final Map<String, dynamic> data = new Map<String, dynamic>(); | ||||
| //     data['departmentName'] = this.departmentName; | ||||
| //     data['departmentCode'] = this.departmentCode; | ||||
| //     data['ntCode'] = this.ntCode; | ||||
| //     data['costCenterNumber'] = this.costCenterNumber; | ||||
| //     data['costCenterName'] = this.costCenterName; | ||||
| //     data['name'] = this.name; | ||||
| //     data['id'] = this.id; | ||||
| //     data['createdBy'] = this.createdBy; | ||||
| //     data['createdDate'] = this.createdDate; | ||||
| //     data['modifiedBy'] = this.modifiedBy; | ||||
| //     data['modifiedDate'] = this.modifiedDate; | ||||
| //     return data; | ||||
| //   } | ||||
| // } | ||||
| @ -0,0 +1,34 @@ | ||||
| import 'dart:convert'; | ||||
| 
 | ||||
| import 'package:http/http.dart'; | ||||
| import 'package:test_sa/models/new_models/traf_department.dart'; | ||||
| import 'package:test_sa/providers/loading_list_notifier.dart'; | ||||
| 
 | ||||
| import '../../controllers/api_routes/api_manager.dart'; | ||||
| import '../../controllers/api_routes/urls.dart'; | ||||
| import '../../models/lookup.dart'; | ||||
| 
 | ||||
| class DepartmentLookupProvider extends LoadingListNotifier<TrafDepartment> { | ||||
|   @override | ||||
|   Future getData({int? id}) async { | ||||
|     if (loading == true) return -2; | ||||
|     loading = true; | ||||
|     notifyListeners(); | ||||
|     try { | ||||
|       Response response = await ApiManager.instance.get(URLs.getDepartmentBasedOnSite + "?customerId=$id"); | ||||
|       stateCode = response.statusCode; | ||||
|       if (response.statusCode >= 200 && response.statusCode < 300) { | ||||
|         List categoriesListJson = json.decode(response.body)["data"]; | ||||
|         items = categoriesListJson.map((item) => TrafDepartment.fromJson(item)).toList(); | ||||
|       } | ||||
|       loading = false; | ||||
|       notifyListeners(); | ||||
|       return response.statusCode; | ||||
|     } catch (error) { | ||||
|       loading = false; | ||||
|       stateCode = -1; | ||||
|       notifyListeners(); | ||||
|       return -1; | ||||
|     } | ||||
|   } | ||||
| } | ||||
					Loading…
					
					
				
		Reference in New Issue