build_app
This commit is contained in:
		
							parent
							
								
									35b5b67985
								
							
						
					
					
						commit
						e5b0a100d5
					
				
							
								
								
									
										8
									
								
								testflutterdd02-dbtdt-d/authsec_mysql/mysql/wf_table/wf_table.sql
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										8
									
								
								testflutterdd02-dbtdt-d/authsec_mysql/mysql/wf_table/wf_table.sql
									
									
									
									
									
										Executable file
									
								
							| @ -0,0 +1,8 @@ | ||||
| CREATE TABLE dbtdt.Ad6(id BIGINT NOT NULL AUTO_INCREMENT, country int, district VARCHAR(400), description VARCHAR(400), state VARCHAR(400), name VARCHAR(400),  PRIMARY KEY (id)); | ||||
| 
 | ||||
| CREATE TABLE dbtdt.Country(id BIGINT NOT NULL AUTO_INCREMENT, active VARCHAR(400), description VARCHAR(400), name VARCHAR(400),  PRIMARY KEY (id)); | ||||
| 
 | ||||
| CREATE TABLE dbtdt.State(id BIGINT NOT NULL AUTO_INCREMENT, active VARCHAR(400), description VARCHAR(400), state_name VARCHAR(400), country_name VARCHAR(400),  PRIMARY KEY (id)); | ||||
| 
 | ||||
| CREATE TABLE dbtdt.District(id BIGINT NOT NULL AUTO_INCREMENT, district_name VARCHAR(400), active VARCHAR(400), description VARCHAR(400), state_name VARCHAR(400),  PRIMARY KEY (id)); | ||||
| 
 | ||||
| @ -0,0 +1,146 @@ | ||||
| import 'dart:typed_data'; | ||||
| import 'package:dio/dio.dart'; | ||||
| import 'package:http_parser/http_parser.dart'; | ||||
| import '../../../../resources/api_constants.dart'; | ||||
| import '../../../../data/network/base_network_service.dart'; | ||||
| import '../../../../data/network/network_api_service.dart'; | ||||
| 
 | ||||
| class Ad6ApiService { | ||||
|   final String baseUrl = ApiConstants.baseUrl; | ||||
| 
 | ||||
|       final BaseNetworkService _helper = NetworkApiService(); | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|    Future<List<Map<String, dynamic>>> getEntities() async { | ||||
| 
 | ||||
|     try { | ||||
|       final response = await _helper.getGetApiResponse('$baseUrl/Ad6/Ad6'); | ||||
|       final entities = (response as List).cast<Map<String, dynamic>>(); | ||||
|       return entities; | ||||
|     } catch (e) { | ||||
|       throw Exception('Failed to get all entities: $e'); | ||||
|     } | ||||
|   } | ||||
| Future<List<Map<String, dynamic>>> getAllWithPagination( | ||||
|        int page, int size) async { | ||||
|     try { | ||||
|             final response = | ||||
|           await _helper.getGetApiResponse('$baseUrl/Ad6/Ad6/getall/page?page=$page&size=$size'); | ||||
|       final entities = | ||||
|           (response['content'] as List).cast<Map<String, dynamic>>(); | ||||
|       return entities; | ||||
|     } catch (e) { | ||||
|       throw Exception('Failed to get all without pagination: $e'); | ||||
|     } | ||||
|   } | ||||
|   Future<Map<String, dynamic>> createEntity( | ||||
|        Map<String, dynamic> entity) async { | ||||
|     try { | ||||
|             print("in post api$entity"); | ||||
|       final response = | ||||
|           await _helper.getPostApiResponse('$baseUrl/Ad6/Ad6', entity); | ||||
| 
 | ||||
|       print(entity); | ||||
| 
 | ||||
|       // Assuming the response is a Map<String, dynamic> | ||||
|       Map<String, dynamic> responseData = response; | ||||
| 
 | ||||
|       return responseData; | ||||
|     } catch (e) { | ||||
|       throw Exception('Failed to create entity: $e'); | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|   Future<void> updateEntity( int entityId, Map<String, dynamic> entity) async { | ||||
|     try { | ||||
|      await _helper.getPutApiResponse('$baseUrl/Ad6/Ad6/$entityId', | ||||
|       entity);                print(entity); | ||||
| 
 | ||||
|     } catch (e) { | ||||
|       throw Exception('Failed to update entity: $e'); | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
|   Future<void> deleteEntity( int entityId) async { | ||||
|     try { | ||||
|  await _helper.getDeleteApiResponse('$baseUrl/Ad6/Ad6/$entityId'); | ||||
|     } catch (e) { | ||||
|       throw Exception('Failed to delete entity: $e'); | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|   | ||||
| 
 | ||||
| 
 | ||||
|   Future<List<Map<String, dynamic>>> getfirstState_name() async { | ||||
|     try { | ||||
|       final response = await _helper | ||||
|           .getGetApiResponse('$baseUrl/State_name_ListFilter1/State_name_ListFilter1'); | ||||
|       final entities = (response as List).cast<Map<String, dynamic>>(); | ||||
|       return entities; | ||||
|     } catch (e) { | ||||
|       throw Exception('Failed to get first dd: $e'); | ||||
|     } | ||||
|   } | ||||
|   Future<List<Map<String, dynamic>>> getsecondState_name(String name) async { | ||||
|     try { | ||||
|       final response = | ||||
|           await _helper.getGetApiResponse('$baseUrl/State_name_ListFilter1/State_name_ListFilter11/$name'); | ||||
|       final entities = (response as List).cast<Map<String, dynamic>>(); | ||||
|       return entities; | ||||
|     } catch (e) { | ||||
|       throw Exception('Failed to get first dd: $e'); | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
| 
 | ||||
|   | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|   | ||||
| 
 | ||||
| 
 | ||||
|   Future<List<Map<String, dynamic>>> getfirstDistrict_name() async { | ||||
|     try { | ||||
|       final response = await _helper | ||||
|           .getGetApiResponse('$baseUrl/District_name_ListFilter1/District_name_ListFilter1'); | ||||
|       final entities = (response as List).cast<Map<String, dynamic>>(); | ||||
|       return entities; | ||||
|     } catch (e) { | ||||
|       throw Exception('Failed to get first dd: $e'); | ||||
|     } | ||||
|   } | ||||
|   Future<List<Map<String, dynamic>>> getsecondDistrict_name(String name) async { | ||||
|     try { | ||||
|       final response = | ||||
|           await _helper.getGetApiResponse('$baseUrl/District_name_ListFilter1/District_name_ListFilter11/$name'); | ||||
|       final entities = (response as List).cast<Map<String, dynamic>>(); | ||||
|       return entities; | ||||
|     } catch (e) { | ||||
|       throw Exception('Failed to get first dd: $e'); | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
| 
 | ||||
|   | ||||
| 
 | ||||
| 
 | ||||
| } | ||||
| @ -0,0 +1,86 @@ | ||||
| // ignore_for_file: use_build_context_synchronously | ||||
| import 'dart:convert'; | ||||
| import 'package:flutter/material.dart'; | ||||
| import 'package:file_picker/file_picker.dart'; | ||||
| import 'package:image_picker/image_picker.dart'; | ||||
| import 'package:provider/provider.dart'; | ||||
| import '../Ad6_viewModel/Ad6_view_model_screen.dart'; | ||||
| import 'Ad6_fields.dart';import 'package:base_project/BuilderField/shared/ui/entity_screens.dart'; | ||||
| import '../../../../utils/image_constant.dart'; | ||||
| import '../../../../utils/size_utils.dart'; | ||||
| import '../../../../theme/app_style.dart'; | ||||
| import '../../../../widgets/app_bar/appbar_image.dart'; | ||||
| import '../../../../widgets/app_bar/appbar_title.dart'; | ||||
| import '../../../../widgets/app_bar/custom_app_bar.dart'; | ||||
| import '../../../../widgets/custom_button.dart'; | ||||
| import '../../../../widgets/custom_text_form_field.dart';  | ||||
| import '../../../../widgets/custom_dropdown_field.dart'; | ||||
| import 'dart:math'; | ||||
| import 'package:qr_flutter/qr_flutter.dart'; | ||||
| import 'package:barcode_widget/barcode_widget.dart'; | ||||
| import 'package:intl/intl.dart'; | ||||
|   | ||||
| import 'package:autocomplete_textfield/autocomplete_textfield.dart'; | ||||
| import 'package:http/http.dart' as http; | ||||
| import 'package:flutter/services.dart'; | ||||
| import 'package:image_picker/image_picker.dart'; | ||||
| import 'package:fluttertoast/fluttertoast.dart'; | ||||
| import '../../../../Reuseable/reusable_date_picker_field.dart'; | ||||
| import '../../../../Reuseable/reusable_date_time_picker_field.dart' | ||||
| ;import 'package:multi_select_flutter/multi_select_flutter.dart'; | ||||
| import 'package:just_audio/just_audio.dart'; | ||||
| import 'package:video_player/video_player.dart'; | ||||
| import 'package:google_fonts/google_fonts.dart'; | ||||
| import 'package:lottie/lottie.dart'; | ||||
| import '../../../../utils/toast_messages/toast_message_util.dart'; | ||||
| import 'dart:io'; | ||||
| import '../../../../Reuseable/reusable_text_field.dart'; | ||||
| import '../../../../Reuseable/reusable_dropdown_field.dart'; | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| class Ad6CreateEntityScreen extends StatefulWidget { | ||||
|   const Ad6CreateEntityScreen({super.key}); | ||||
| 
 | ||||
|   @override | ||||
|   _Ad6CreateEntityScreenState createState() => _Ad6CreateEntityScreenState(); | ||||
| } | ||||
| 
 | ||||
| class _Ad6CreateEntityScreenState extends State<Ad6CreateEntityScreen> { | ||||
| 
 | ||||
| final Map<String, dynamic> formData = {}; | ||||
|   final _formKey = GlobalKey<FormState>(); | ||||
|    | ||||
|   @override | ||||
|   Widget build(BuildContext context) { | ||||
|     return Consumer<Ad6ViewModelScreen>( | ||||
|       builder: (context, viewModel, child) { | ||||
|         return EntityCreateScreen( | ||||
|           fields: Ad6Fields.getFields(context), | ||||
|           onSubmit: (data) => _handleSubmit(data), | ||||
|           title: 'Ad6', | ||||
|           isLoading: viewModel.isLoading, | ||||
|           errorMessage: | ||||
|               viewModel.errorMessage.isNotEmpty ? viewModel.errorMessage : null, | ||||
|         ); | ||||
|       }, | ||||
|     ); | ||||
|   } | ||||
| 
 | ||||
|   Future<void> _handleSubmit(Map<String, dynamic> formData) async { | ||||
|     final provider = | ||||
|         Provider.of<Ad6ViewModelScreen>(context, listen: false); | ||||
|     final success = await provider.createEntity(formData); | ||||
| 
 | ||||
|     if (success && mounted) { | ||||
|       Navigator.pop(context); | ||||
|     } | ||||
|   } | ||||
| } | ||||
| @ -0,0 +1,94 @@ | ||||
| // ignore_for_file: use_build_context_synchronously | ||||
| import 'package:flutter/material.dart'; | ||||
| import 'package:provider/provider.dart'; | ||||
| import '../../../../BuilderField/shared/ui/entity_details.dart'; | ||||
| import '../Ad6_viewModel/Ad6_view_model_screen.dart'; | ||||
| import 'Ad6_update_entity_screen.dart'; | ||||
| 
 | ||||
| class Ad6DetailsScreen extends StatefulWidget { | ||||
|   final Map<String, dynamic> entity; | ||||
| 
 | ||||
|   const Ad6DetailsScreen({ | ||||
|     super.key, | ||||
|     required this.entity, | ||||
|   }); | ||||
| 
 | ||||
|   @override | ||||
|   State<Ad6DetailsScreen> createState() => _Ad6DetailsScreenState(); | ||||
| } | ||||
| 
 | ||||
| class _Ad6DetailsScreenState extends State<Ad6DetailsScreen> { | ||||
|   void _navigateToUpdateScreen(Map<String, dynamic> entity) { | ||||
|     Navigator.push( | ||||
|       context, | ||||
|       MaterialPageRoute( | ||||
|         builder: (context) => ChangeNotifierProvider( | ||||
|           create: (context) => Ad6ViewModelScreen(), | ||||
|           child: Ad6UpdateEntityScreen(entity: entity), | ||||
|         ), | ||||
|       ), | ||||
|     ).then((_) { | ||||
|       // Refresh the details screen with updated data | ||||
|       setState(() {}); | ||||
|     }); | ||||
|   } | ||||
| 
 | ||||
|   void _showDeleteDialog(Map<String, dynamic> entity) { | ||||
|     showDialog( | ||||
|       context: context, | ||||
|       builder: (BuildContext context) { | ||||
|         return AlertDialog( | ||||
|           title: const Text('Confirm Deletion'), | ||||
|           content: const Text('Are you sure you want to delete this Ad6?'), | ||||
|           actions: [ | ||||
|             TextButton( | ||||
|               child: const Text('Cancel'), | ||||
|               onPressed: () { | ||||
|                 Navigator.of(context).pop(); | ||||
|               }, | ||||
|             ), | ||||
|             TextButton( | ||||
|               child: const Text('Delete'), | ||||
|               onPressed: () async { | ||||
|                 Navigator.of(context).pop(); | ||||
|                 final vm = | ||||
|                     Provider.of<Ad6ViewModelScreen>(context, listen: false); | ||||
|                 final success = await vm.deleteEntity(entity['id']); | ||||
|                 if (success && mounted) { | ||||
|                   Navigator.pop(context); // Go back to list | ||||
|                 } | ||||
|               }, | ||||
|             ), | ||||
|           ], | ||||
|         ); | ||||
|       }, | ||||
|     ); | ||||
|   } | ||||
| 
 | ||||
|   @override | ||||
|   Widget build(BuildContext context) { | ||||
|     return Consumer<Ad6ViewModelScreen>( | ||||
|       builder: (context, viewModel, child) { | ||||
|         return EntityDetails( | ||||
|           entity: widget.entity, | ||||
|           onEdit: (entity) => _navigateToUpdateScreen(entity), | ||||
|           onDelete: (entity) => _showDeleteDialog(entity), | ||||
|           title: 'Ad6', | ||||
|           displayFields: [ | ||||
|   {'key': 'name', 'label': 'Name', 'type': 'text'}, | ||||
| 
 | ||||
|   {'key': 'description', 'label': 'description', 'type': 'text'}, | ||||
| 
 | ||||
|   {'key': 'country', 'label': 'country', 'type': 'select'}, | ||||
| 
 | ||||
|   {'key': 'state', 'label': 'state', 'type': 'dependent_dropdown'}, | ||||
| 
 | ||||
|   {'key': 'district', 'label': 'district', 'type': 'dependent_dropdown'}, | ||||
| 
 | ||||
|           ], | ||||
|           isLoading: viewModel.isLoading, | ||||
|         ); | ||||
|       }, | ||||
|     ); | ||||
|   } | ||||
| } | ||||
| @ -0,0 +1,154 @@ | ||||
| // ignore_for_file: use_build_context_synchronously | ||||
| import 'package:flutter/material.dart'; | ||||
| import 'package:intl/intl.dart'; | ||||
| import 'package:base_project/BuilderField/shared/ui/entity_list.dart'; | ||||
| import 'Ad6_create_entity_screen.dart'; | ||||
| import 'Ad6_update_entity_screen.dart'; | ||||
| import '../Ad6_viewModel/Ad6_view_model_screen.dart'; | ||||
| import 'Ad6_details_screen.dart';import 'package:flutter/services.dart'; | ||||
| import 'package:speech_to_text/speech_to_text.dart' as stt; | ||||
| import '../../../../theme/app_style.dart'; | ||||
| import '../../../../utils/size_utils.dart'; | ||||
| import '../../../../widgets/custom_icon_button.dart'; | ||||
| import '../../../../utils/image_constant.dart'; | ||||
| import '../../../../widgets/app_bar/appbar_image.dart'; | ||||
| import '../../../../widgets/app_bar/appbar_title.dart'; | ||||
| import '../../../../widgets/app_bar/custom_app_bar.dart'; | ||||
| import '../../../../theme/app_decoration.dart'; | ||||
| import 'package:multi_select_flutter/multi_select_flutter.dart'; | ||||
| import '../../../../Reuseable/reusable_text_field.dart'; | ||||
| import 'package:provider/provider.dart'; | ||||
| import '../../../../utils/toast_messages/toast_message_util.dart'; | ||||
| import 'package:fluttertoast/fluttertoast.dart'; | ||||
| 
 | ||||
| class Ad6_entity_list_screen extends StatefulWidget { | ||||
|   static const String routeName = '/entity-list'; | ||||
| 
 | ||||
|   @override | ||||
|   _Ad6_entity_list_screenState createState() => _Ad6_entity_list_screenState(); | ||||
| } | ||||
| 
 | ||||
| class _Ad6_entity_list_screenState extends State<Ad6_entity_list_screen> { | ||||
|   @override | ||||
|   void initState() { | ||||
|     super.initState(); | ||||
|     _loadData(); | ||||
|   } | ||||
| 
 | ||||
|   void _loadData() { | ||||
|     WidgetsBinding.instance.addPostFrameCallback((_) { | ||||
|       if (mounted) { | ||||
|         final vm = Provider.of<Ad6ViewModelScreen>(context, listen: false); | ||||
|         vm.getAllWithPagination(refresh: true); | ||||
|       } | ||||
|     }); | ||||
|   } | ||||
| 
 | ||||
|   void _navigateToCreateScreen() { | ||||
|     Navigator.push( | ||||
|       context, | ||||
|       MaterialPageRoute( | ||||
|         builder: (context) => ChangeNotifierProvider( | ||||
|           create: (context) => Ad6ViewModelScreen(), | ||||
|           child: const Ad6CreateEntityScreen(), | ||||
|         ), | ||||
|       ), | ||||
|     ).then((_) { | ||||
|       final vm = Provider.of<Ad6ViewModelScreen>(context, listen: false); | ||||
|       vm.refreshData(); | ||||
|     }); | ||||
|   } | ||||
| 
 | ||||
|   void _navigateToUpdateScreen(Map<String, dynamic> entity) { | ||||
|     Navigator.push( | ||||
|       context, | ||||
|       MaterialPageRoute( | ||||
|         builder: (context) => ChangeNotifierProvider( | ||||
|           create: (context) => Ad6ViewModelScreen(), | ||||
|           child: Ad6UpdateEntityScreen(entity: entity), | ||||
|         ), | ||||
|       ), | ||||
|     ).then((_) { | ||||
|       final vm = Provider.of<Ad6ViewModelScreen>(context, listen: false); | ||||
|       vm.refreshData(); | ||||
|     }); | ||||
|   } | ||||
| 
 | ||||
|   void _navigateToDetailsScreen(Map<String, dynamic> entity) { | ||||
|     Navigator.push( | ||||
|       context, | ||||
|       MaterialPageRoute( | ||||
|         builder: (context) => ChangeNotifierProvider( | ||||
|           create: (context) => Ad6ViewModelScreen(), | ||||
|           child: Ad6DetailsScreen(entity: entity), | ||||
|         ), | ||||
|       ), | ||||
|     ); | ||||
|   } | ||||
| 
 | ||||
|   void _showDeleteDialog(Map<String, dynamic> entity) { | ||||
|  final parentContext = context;  | ||||
|     showDialog( | ||||
|       context: context, | ||||
|       builder: (BuildContext context) { | ||||
|         return AlertDialog( | ||||
|           title: const Text('Confirm Deletion'), | ||||
|           content: const Text('Are you sure you want to delete this Ad6?'), | ||||
|           actions: [ | ||||
|             TextButton( | ||||
|               child: const Text('Cancel'), | ||||
|               onPressed: () { | ||||
|                 Navigator.of(context).pop(); | ||||
|               }, | ||||
|             ), | ||||
|             TextButton( | ||||
|               child: const Text('Delete'), | ||||
|               onPressed: () async { | ||||
|                 Navigator.of(context).pop(); | ||||
|                 final vm = | ||||
|                     Provider.of<Ad6ViewModelScreen>(parentContext, listen: false); | ||||
|                 await vm.deleteEntity(entity['id']); | ||||
|               }, | ||||
|             ), | ||||
|           ], | ||||
|         ); | ||||
|       }, | ||||
|     ); | ||||
|   } | ||||
| 
 | ||||
|   @override | ||||
|   Widget build(BuildContext context) { | ||||
|     return Consumer<Ad6ViewModelScreen>( | ||||
|       builder: (context, viewModel, child) { | ||||
|         return EntityList( | ||||
|           entities: viewModel.filteredList, | ||||
|           isLoading: viewModel.isLoading, | ||||
|           errorMessage: | ||||
|               viewModel.errorMessage.isNotEmpty ? viewModel.errorMessage : null, | ||||
|           hasMoreData: viewModel.hasMoreData, | ||||
|           searchQuery: viewModel.searchQuery, | ||||
|           onSearchChanged: (query) => viewModel.searchad6(query), | ||||
|           onEdit: (entity) => _navigateToUpdateScreen(entity), | ||||
|           onDelete: (entity) => _showDeleteDialog(entity), | ||||
|           onTap: (entity) => _navigateToDetailsScreen(entity), | ||||
|           onRefresh: () => viewModel.refreshData(), | ||||
|           onLoadMore: () => viewModel.getAllWithPagination(), | ||||
|           title: 'Ad6', | ||||
|           onAddNew: _navigateToCreateScreen, | ||||
|           displayFields: [ | ||||
|   {'key': 'name', 'label': 'Name', 'type': 'text'}, | ||||
| 
 | ||||
|   {'key': 'description', 'label': 'description', 'type': 'text'}, | ||||
| 
 | ||||
|   {'key': 'country', 'label': 'country', 'type': 'select'}, | ||||
| 
 | ||||
|   {'key': 'state', 'label': 'state', 'type': 'dependent_dropdown'}, | ||||
| 
 | ||||
|   {'key': 'district', 'label': 'district', 'type': 'dependent_dropdown'}, | ||||
| 
 | ||||
|           ], | ||||
|         ); | ||||
|       }, | ||||
|     ); | ||||
|   } | ||||
| } | ||||
| @ -0,0 +1,127 @@ | ||||
| import 'package:base_project/BuilderField/shared/fields/number_field.dart'; | ||||
| import 'package:base_project/BuilderField/shared/fields/password_field.dart'; | ||||
| import 'package:base_project/BuilderField/shared/fields/phone_field.dart'; | ||||
| import 'package:base_project/BuilderField/shared/fields/custom_text_field.dart'; | ||||
| 
 | ||||
| import '../../../../BuilderField/shared/fields/base_field.dart'; | ||||
| 
 | ||||
| import '../../../../BuilderField/shared/fields/date_field.dart'; | ||||
| import '../../../../BuilderField/shared/fields/datetime_field.dart'; | ||||
| import '../../../../BuilderField/shared/fields/email_field.dart'; | ||||
| import 'package:base_project/BuilderField/shared/fields/url_field.dart'; | ||||
| import 'package:flutter/material.dart'; | ||||
| import 'package:provider/provider.dart'; | ||||
| 
 | ||||
| import '../../../../BuilderField/shared/fields/custom_text_field.dart' as shared_text; | ||||
| import '../../../../BuilderField/shared/fields/one_to_one_relation_field.dart'; | ||||
| import '../../../../BuilderField/shared/fields/calculated_field.dart'; | ||||
| import '../../../../BuilderField/shared/fields/one_to_many_field.dart'; | ||||
| import '../../../../BuilderField/shared/fields/value_list_picker_field.dart'; | ||||
| import '../../../../BuilderField/shared/fields/captcha_field.dart'; | ||||
| import '../../../../BuilderField/shared/fields/switch_field.dart'; | ||||
| import '../../../../BuilderField/shared/fields/url_field.dart'; | ||||
| 
 | ||||
| import '../../../../BuilderField/shared/fields/audio_upload_field.dart'; | ||||
| import '../../../../BuilderField/shared/fields/checkbox_field.dart'; | ||||
| import '../../../../BuilderField/shared/fields/file_upload_field.dart'; | ||||
| import '../../../../BuilderField/shared/fields/image_upload_field.dart'; | ||||
| import '../../../../BuilderField/shared/fields/radio_field.dart'; | ||||
| import '../../../../BuilderField/shared/fields/video_upload_field.dart'; | ||||
| 
 | ||||
| import '../../../../BuilderField/shared/fields/autocomplete_dropdown_field.dart'; | ||||
| import '../../../../BuilderField/shared/fields/autocomplete_multiselect_field.dart'; | ||||
| import '../../../../BuilderField/shared/fields/one_to_one_relation_field.dart'; | ||||
| import '../../../../BuilderField/shared/fields/data_grid_field.dart'; | ||||
| import '../../../../BuilderField/shared/fields/dropdown_field.dart'; | ||||
| import '../../../../BuilderField/shared/fields/dynamic_dropdown_field.dart'; | ||||
| import '../../../../BuilderField/shared/fields/dynamic_multiselect_dropdown_field.dart'; | ||||
| import '../../../../BuilderField/shared/fields/static_multiselect_field.dart'; | ||||
| import '../../../../BuilderField/shared/fields/currency_field.dart'; | ||||
| import '../../../../BuilderField/shared/fields/field_group_field.dart'; | ||||
| import '../../../../BuilderField/shared/fields/qr_code_field.dart'; | ||||
| import '../../../../BuilderField/shared/fields/barcode_field.dart'; | ||||
| import '../../../../BuilderField/shared/fields/dependent_dropdown_field.dart'; | ||||
|  import '../Ad6_viewModel/Ad6_view_model_screen.dart';/// Field definitions for Ad6 entity | ||||
| /// This defines the structure and validation for Ad6 forms | ||||
| class Ad6Fields { | ||||
|   /// Get field definitions for Ad6 entity | ||||
|   static List<BaseField> getFields(BuildContext context) { | ||||
|     final viewModel = | ||||
|         Provider.of<Ad6ViewModelScreen>(context, listen: false); | ||||
|     return [ | ||||
|       // Basic Information | ||||
|  CustomTextField( | ||||
|         fieldKey: 'name', | ||||
|         label: 'Name', | ||||
|         hint: 'Enter Name', | ||||
|         isRequired: true, | ||||
|         maxLength: 50, | ||||
|       ), | ||||
| 
 | ||||
|  CustomTextField( | ||||
|         fieldKey: 'description', | ||||
|         label: 'description', | ||||
|         hint: 'Enter description', | ||||
|         isRequired: true, | ||||
|         maxLength: 50, | ||||
|       ), | ||||
| 
 | ||||
|  DynamicDropdownField( | ||||
|         fieldKey: 'country', | ||||
|         label: 'Select country', | ||||
|          hint: 'Search and select', | ||||
|         optionsLoader: () => viewModel.getcountry(), | ||||
| 
 | ||||
|   | ||||
|         valueKey: 'name', | ||||
|         displayKey: 'name', | ||||
|   | ||||
| 
 | ||||
|       ), | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|  DependentDropdownField( | ||||
|         fieldKey: 'state', | ||||
|         label: 'state', | ||||
|         hint: 'Select state', | ||||
| 
 | ||||
|   | ||||
|         dependentFieldKey: 'country', | ||||
|   | ||||
| 
 | ||||
|          optionsLoader: (parentVal) => viewModel.getstateDependent(parentVal), | ||||
| 
 | ||||
|   | ||||
|         valueKey: 'state_name', | ||||
|         displayKey: 'state_name', | ||||
|   | ||||
|   | ||||
|       ), | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|  DependentDropdownField( | ||||
|         fieldKey: 'district', | ||||
|         label: 'district', | ||||
|         hint: 'Select district', | ||||
| 
 | ||||
|   | ||||
|         dependentFieldKey: 'state', | ||||
|   | ||||
| 
 | ||||
|          optionsLoader: (parentVal) => viewModel.getdistrictDependent(parentVal), | ||||
| 
 | ||||
|   | ||||
|         valueKey: 'district_name', | ||||
|         displayKey: 'district_name', | ||||
|   | ||||
|   | ||||
|       ), | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|     ]; | ||||
|   } | ||||
| } | ||||
| @ -0,0 +1,81 @@ | ||||
| // ignore_for_file: use_build_context_synchronously | ||||
| import 'dart:convert'; | ||||
| import 'package:provider/provider.dart'; | ||||
| import '../Ad6_viewModel/Ad6_view_model_screen.dart'; | ||||
| import 'package:base_project/BuilderField/shared/ui/entity_screens.dart'; | ||||
| import 'Ad6_fields.dart';import '../../../../utils/image_constant.dart'; | ||||
| import '../../../../utils/size_utils.dart'; | ||||
| import '../../../../theme/app_style.dart'; | ||||
| import '../../../../widgets/app_bar/appbar_image.dart'; | ||||
| import '../../../../widgets/app_bar/appbar_title.dart'; | ||||
| import '../../../../widgets/app_bar/custom_app_bar.dart'; | ||||
| import 'package:barcode_widget/barcode_widget.dart'; | ||||
| import 'package:fluttertoast/fluttertoast.dart'; | ||||
| import '../../../../widgets/custom_button.dart'; | ||||
| import '../../../../widgets/custom_text_form_field.dart'; | ||||
| import 'package:flutter/material.dart'; | ||||
| import 'package:autocomplete_textfield/autocomplete_textfield.dart'; | ||||
| import 'package:qr_flutter/qr_flutter.dart'; | ||||
| import 'package:intl/intl.dart'; | ||||
| 
 | ||||
| import 'dart:math'; | ||||
| import '../../../../Reuseable/reusable_text_field.dart'; | ||||
| import '../../../../Reuseable/reusable_date_picker_field.dart'; | ||||
| import '../../../../Reuseable/reusable_date_time_picker_field.dart'; | ||||
| import '../../../../Reuseable/reusable_dropdown_field.dart'; | ||||
| import 'package:flutter/services.dart'; | ||||
| class Ad6UpdateEntityScreen extends StatefulWidget { | ||||
|     final Map<String, dynamic> entity; | ||||
| 
 | ||||
| 
 | ||||
|   Ad6UpdateEntityScreen({required this.entity}); | ||||
| 
 | ||||
|   @override | ||||
|   _Ad6UpdateEntityScreenState createState() => _Ad6UpdateEntityScreenState(); | ||||
| } | ||||
| 
 | ||||
| class _Ad6UpdateEntityScreenState extends State<Ad6UpdateEntityScreen> { | ||||
|   final _formKey = GlobalKey<FormState>(); | ||||
| 
 | ||||
| @override | ||||
|   Widget build(BuildContext context) { | ||||
|     return Consumer<Ad6ViewModelScreen>( | ||||
|       builder: (context, viewModel, child) { | ||||
| // Start with all fields, then remove upload fields (generic filter by keys) | ||||
|         final Set<String> hiddenKeys = {  | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|  }; | ||||
|         final fields = Ad6Fields.getFields(context) | ||||
|             .where((f) => !hiddenKeys.contains(f.fieldKey)) | ||||
|             .toList();        return EntityUpdateScreen( | ||||
|           fields: fields, | ||||
|           initialData: widget.entity, | ||||
|           onSubmit: (data) => _handleSubmit(data), | ||||
|           title: 'Ad6', | ||||
|           isLoading: viewModel.isLoading, | ||||
|           errorMessage: | ||||
|               viewModel.errorMessage.isNotEmpty ? viewModel.errorMessage : null, | ||||
|         ); | ||||
|       }, | ||||
|     ); | ||||
|   } | ||||
| 
 | ||||
|   Future<void> _handleSubmit(Map<String, dynamic> formData) async { | ||||
|     final provider = | ||||
|         Provider.of<Ad6ViewModelScreen>(context, listen: false); | ||||
|     final success = await provider.updateEntity(widget.entity['id'], formData); | ||||
| 
 | ||||
|     if (success && mounted) { | ||||
|       Navigator.pop(context); | ||||
|     } | ||||
|   } | ||||
| } | ||||
| @ -0,0 +1,123 @@ | ||||
| import 'package:dio/dio.dart'; | ||||
| import '../../../../data/network/base_network_service.dart'; | ||||
| import '../../../../data/network/network_api_service.dart'; | ||||
| import '../../../../resources/api_constants.dart'; | ||||
| import 'package:base_project/data/response/api_response.dart'; | ||||
| 
 | ||||
| class Ad6RepoScreen { | ||||
| 
 | ||||
|   final String baseUrl = ApiConstants.baseUrl; | ||||
|   final BaseNetworkService _helper = NetworkApiService(); | ||||
|   final String _endpointPath = '/Ad6/Ad6'; | ||||
| 
 | ||||
|   Future<ApiResponse<List<Map<String, dynamic>>>> getEntities() async { | ||||
|     try { | ||||
|       final response = | ||||
|           await _helper.getGetApiResponse('$baseUrl$_endpointPath'); | ||||
|       print('Response received: $response'); | ||||
|       List<Map<String, dynamic>> entities = const []; | ||||
|       if (response is List) { | ||||
|         entities = response | ||||
|             .whereType<Map>() | ||||
|             .map((e) => Map<String, dynamic>.from(e as Map)) | ||||
|             .toList(); | ||||
|       } else if (response is Map<String, dynamic>) { | ||||
|         final dynamic content = response['content']; | ||||
|         if (content is List) { | ||||
|           entities = content | ||||
|               .whereType<Map>() | ||||
|               .map((e) => Map<String, dynamic>.from(e as Map)) | ||||
|               .toList(); | ||||
|         } | ||||
|       } | ||||
|       return ApiResponse.success(entities); | ||||
|     } catch (e) { | ||||
|       print(' error got $e'); | ||||
|       return ApiResponse.error('Failed to get all entities: $e'); | ||||
|     } | ||||
|   }  | ||||
| 
 | ||||
|   Future<ApiResponse<List<Map<String, dynamic>>>> getAllWithPagination( | ||||
|       int page, int size) async { | ||||
|     try { | ||||
|       final response = await _helper.getGetApiResponse( | ||||
|           '$baseUrl$_endpointPath/getall/page?page=$page&size=$size'); | ||||
| 
 | ||||
|       if (response is Map<String, dynamic> && response['content'] is List) { | ||||
|         final List<Map<String, dynamic>> entities = | ||||
|             (response['content'] as List).cast<Map<String, dynamic>>().toList(); | ||||
|         return ApiResponse.success(entities); | ||||
|       } else { | ||||
|         return ApiResponse.error('Invalid response format'); | ||||
|       } | ||||
|     } catch (e) { | ||||
|       return ApiResponse.error('Failed to get all without pagination: $e'); | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
|   Future<ApiResponse<Map<String, dynamic>>> createEntity( | ||||
|       Map<String, dynamic> entity) async { | ||||
|     try { | ||||
|       print("in post api$entity"); | ||||
|       final response = | ||||
|           await _helper.getPostApiResponse('$baseUrl$_endpointPath', entity); | ||||
|       return ApiResponse.success(response as Map<String, dynamic>); | ||||
|     } catch (e) { | ||||
|       return ApiResponse.error('Failed to create entity: $e'); | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
|   Future<ApiResponse<Map<String, dynamic>>> updateEntity( | ||||
|       int entityId, Map<String, dynamic> entity) async { | ||||
|     try { | ||||
|       final response = await _helper.getPutApiResponse( | ||||
|           '$baseUrl$_endpointPath/$entityId', entity); | ||||
|       return ApiResponse.success(response as Map<String, dynamic>); | ||||
|     } catch (e) { | ||||
|       return ApiResponse.error('Failed to update entity: $e'); | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
|   Future<ApiResponse<void>> deleteEntity(int entityId) async { | ||||
|     try { | ||||
|       await _helper.getDeleteApiResponse('$baseUrl$_endpointPath/$entityId'); | ||||
|       return ApiResponse.success(null); | ||||
|     } catch (e) { | ||||
|       return ApiResponse.error('Failed to delete entity: $e'); | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|  Future<dynamic> getcountry() async { | ||||
|     try { | ||||
|       String apiUrl = "$baseUrl/Country_ListFilter1/Country_ListFilter1"; | ||||
|       final response = await _helper.getGetApiResponse(apiUrl); | ||||
|       return response; | ||||
|     } catch (e) { | ||||
|       throw Exception('Failed to Get: $e'); | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
|  Future<dynamic> getstateDependent(String name) async { | ||||
|     try { | ||||
|       String apiUrl = "$baseUrl/State_ListFilter1/State_ListFilter11/$name"; | ||||
|       final response = await _helper.getGetApiResponse(apiUrl); | ||||
|       return response; | ||||
|     } catch (e) { | ||||
|       throw Exception('Failed to Get: $e'); | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
|  Future<dynamic> getdistrictDependent(String name) async { | ||||
|     try { | ||||
|       String apiUrl = "$baseUrl/District_ListFilter1/District_ListFilter11/$name"; | ||||
|       final response = await _helper.getGetApiResponse(apiUrl); | ||||
|       return response; | ||||
|     } catch (e) { | ||||
|       throw Exception('Failed to Get: $e'); | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
| } | ||||
| @ -0,0 +1,382 @@ | ||||
| import 'package:base_project/data/response/status.dart'; | ||||
| import 'dart:typed_data'; | ||||
| import 'package:dio/dio.dart'; | ||||
| import 'package:http_parser/http_parser.dart'; | ||||
| import '../../../../utils/toast_messages/toast_message_util.dart'; | ||||
| import '../../../../BuilderField/shared/utils/entity_field_store.dart'; | ||||
| import 'package:flutter/material.dart'; | ||||
| import '../Ad6_Repo/Ad6_repo_screen.dart'; | ||||
| 
 | ||||
| class Ad6ViewModelScreen extends ChangeNotifier{ | ||||
|   final Ad6RepoScreen repo = Ad6RepoScreen(); | ||||
| 
 | ||||
|   | ||||
|   // State variables | ||||
|   List<Map<String, dynamic>> _ad6List = []; | ||||
|   List<Map<String, dynamic>> _filteredList = []; | ||||
|   bool _isLoading = false; | ||||
|   String _errorMessage = ''; | ||||
|   int _currentPage = 0; | ||||
|   int _pageSize = 10; | ||||
|   bool _hasMoreData = true; | ||||
|   String _searchQuery = ''; | ||||
| 
 | ||||
|   // Getters | ||||
|   List<Map<String, dynamic>> get ad6List => _ad6List; | ||||
|   List<Map<String, dynamic>> get filteredList => _filteredList; | ||||
|   bool get isLoading => _isLoading; | ||||
|   String get errorMessage => _errorMessage; | ||||
|   bool get hasMoreData => _hasMoreData; | ||||
|   String get searchQuery => _searchQuery; | ||||
| 
 | ||||
|   // Set loading state | ||||
|   void _setLoading(bool loading) { | ||||
|     _isLoading = loading; | ||||
|     notifyListeners(); | ||||
|   } | ||||
| 
 | ||||
|   // Set error message | ||||
|   void _setError(String error) { | ||||
|     _errorMessage = error; | ||||
|     notifyListeners(); | ||||
|   } | ||||
| 
 | ||||
|   // Clear error | ||||
|   void clearError() { | ||||
|     _errorMessage = ''; | ||||
|     notifyListeners(); | ||||
|   } | ||||
| 
 | ||||
|   // Get ad6 list | ||||
|   Future<void> getEntities() async { | ||||
|     _setLoading(true); | ||||
|     _setError(''); | ||||
| 
 | ||||
|     try { | ||||
|       final response = await repo.getEntities(); | ||||
| 
 | ||||
|       if (response.status == Status.SUCCESS) { | ||||
|         _ad6List = response.data ?? []; | ||||
|         _filteredList = List.from(_ad6List); | ||||
|         _currentPage = 0; | ||||
|         _hasMoreData = true; | ||||
|       } else { | ||||
|         _setError(response.message ?? 'Failed to fetch ad6 list'); | ||||
|       } | ||||
|     } catch (e) { | ||||
|       _setError('Failed to fetch ad6 list: $e'); | ||||
|     } finally { | ||||
|       _setLoading(false); | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
|   // Get ad6 list with pagination | ||||
|   Future<void> getAllWithPagination({bool refresh = false}) async { | ||||
|     if (refresh) { | ||||
|       _currentPage = 0; | ||||
|       _ad6List.clear(); | ||||
|       _filteredList.clear(); | ||||
|       _hasMoreData = true; | ||||
|     } | ||||
| 
 | ||||
|     if (!_hasMoreData || _isLoading) return; | ||||
| 
 | ||||
|     _setLoading(true); | ||||
|     _setError(''); | ||||
| 
 | ||||
|     try { | ||||
|       final response = await repo.getAllWithPagination(_currentPage, _pageSize); | ||||
| 
 | ||||
|       if (response.status == Status.SUCCESS) { | ||||
|         final newItems = response.data ?? []; | ||||
| 
 | ||||
|         if (refresh) { | ||||
|           _ad6List = newItems; | ||||
|         } else { | ||||
|           _ad6List.addAll(newItems); | ||||
|         } | ||||
| 
 | ||||
|         _filteredList = List.from(_ad6List); | ||||
|         _currentPage++; | ||||
| 
 | ||||
|         // Check if we have more data | ||||
|         _hasMoreData = newItems.length == _pageSize; | ||||
|       } else { | ||||
|         _setError(response.message ?? 'Failed to fetch Ad6 list'); | ||||
|       } | ||||
|     } catch (e) { | ||||
|       _setError('Failed to fetch ad6 list: $e'); | ||||
|     } finally { | ||||
|       _setLoading(false); | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|   // Create Ad6 | ||||
|   Future<bool> createEntity(Map<String, dynamic> entity) async { | ||||
|     _setLoading(true); | ||||
|     _setError(''); | ||||
| 
 | ||||
|     try { | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|       final response = await repo.createEntity(entity); | ||||
| 
 | ||||
|       if (response.status == Status.SUCCESS) { | ||||
| // Get the response ID for image upload | ||||
| 
 | ||||
|         final responseId = response.data!['id'].toString(); | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|         ToastMessageUtil.showToast( | ||||
|           message: 'ad6 created successfully', | ||||
|           toastType: ToastType.success, | ||||
|         ); | ||||
| 
 | ||||
|         // Refresh the list | ||||
|         await getEntities(); | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|         return true; | ||||
|       } else { | ||||
|         _setError(response.message ?? 'Failed to create Ad6'); | ||||
|         ToastMessageUtil.showToast( | ||||
|           message: response.message ?? 'Failed to create Ad6', | ||||
|           toastType: ToastType.error, | ||||
|         ); | ||||
|         return false; | ||||
|       } | ||||
|     } catch (e) { | ||||
|       _setError('Failed to create ad6: $e'); | ||||
|       ToastMessageUtil.showToast( | ||||
|         message: 'Failed to create Ad6: $e', | ||||
|         toastType: ToastType.error, | ||||
|       ); | ||||
|       return false; | ||||
|     } finally { | ||||
|       _setLoading(false); | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
|   // Update ad6 | ||||
|   Future<bool> updateEntity(int id, Map<String, dynamic> entity) async { | ||||
|     _setLoading(true); | ||||
|     _setError(''); | ||||
| 
 | ||||
|     try { | ||||
|       final response = await repo.updateEntity(id, entity); | ||||
| 
 | ||||
|       if (response.status == Status.SUCCESS) { | ||||
|         ToastMessageUtil.showToast( | ||||
|           message: 'Ad6 updated successfully', | ||||
|           toastType: ToastType.success, | ||||
|         ); | ||||
| 
 | ||||
|         // Update the item in the list | ||||
|         final index = _ad6List.indexWhere((item) => item['id'] == id); | ||||
|         if (index != -1) { | ||||
|           _ad6List[index] = response.data!; | ||||
|           _filteredList = List.from(_ad6List); | ||||
|           notifyListeners(); | ||||
|         } | ||||
|         return true; | ||||
|       } else { | ||||
|         _setError(response.message ?? 'Failed to update Ad6'); | ||||
|         ToastMessageUtil.showToast( | ||||
|           message: response.message ?? 'Failed to update Ad6', | ||||
|           toastType: ToastType.error, | ||||
|         ); | ||||
|         return false; | ||||
|       } | ||||
|     } catch (e) { | ||||
|       _setError('Failed to update ad6: $e'); | ||||
|       ToastMessageUtil.showToast( | ||||
|         message: 'Failed to update Ad6: $e', | ||||
|         toastType: ToastType.error, | ||||
|       ); | ||||
|       return false; | ||||
|     } finally { | ||||
|       _setLoading(false); | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
|   // Delete ad6 | ||||
|   Future<bool> deleteEntity(int id) async { | ||||
|     _setLoading(true); | ||||
|     _setError(''); | ||||
| 
 | ||||
|     try { | ||||
|       final response = await repo.deleteEntity(id); | ||||
| 
 | ||||
|       if (response.status == Status.SUCCESS) { | ||||
|         ToastMessageUtil.showToast( | ||||
|           message: 'Ad6 deleted successfully', | ||||
|           toastType: ToastType.success, | ||||
|         ); | ||||
| 
 | ||||
|         // Remove the item from the list | ||||
|         _ad6List.removeWhere((item) => item['id'] == id); | ||||
|         _filteredList = List.from(_ad6List); | ||||
|         notifyListeners(); | ||||
|         return true; | ||||
|       } else { | ||||
|         _setError(response.message ?? 'Failed to delete Ad6'); | ||||
|         ToastMessageUtil.showToast( | ||||
|           message: response.message ?? 'Failed to delete Ad6', | ||||
|           toastType: ToastType.error, | ||||
|         ); | ||||
|         return false; | ||||
|       } | ||||
|     } catch (e) { | ||||
|       _setError('Failed to delete ad6: $e'); | ||||
|       ToastMessageUtil.showToast( | ||||
|         message: 'Failed to delete Ad6: $e', | ||||
|         toastType: ToastType.error, | ||||
|       ); | ||||
|       return false; | ||||
|     } finally { | ||||
|       _setLoading(false); | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
|   // Search ad6 | ||||
|   void searchad6(String query) { | ||||
|     _searchQuery = query; | ||||
| 
 | ||||
|     if (query.isEmpty) { | ||||
|       _filteredList = List.from(_ad6List); | ||||
|     } else { | ||||
|       _filteredList = _ad6List.where((item) { | ||||
|         return | ||||
| 
 | ||||
|               | ||||
| (item['name']?.toString().toLowerCase().contains(query.toLowerCase()) ??false) || | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|               | ||||
| (item['description']?.toString().toLowerCase().contains(query.toLowerCase()) ??false) || | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|               | ||||
| (item['country']?.toString().toLowerCase().contains(query.toLowerCase()) ??false) || | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|               | ||||
| (item['state']?.toString().toLowerCase().contains(query.toLowerCase()) ??false) || | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|               | ||||
| (item['district']?.toString().toLowerCase().contains(query.toLowerCase()) ??false)  | ||||
| 
 | ||||
| 
 | ||||
| ; | ||||
|       }).toList(); | ||||
|     } | ||||
|     notifyListeners(); | ||||
|   } | ||||
| 
 | ||||
|   // Clear search | ||||
|   void clearSearch() { | ||||
|     _searchQuery = ''; | ||||
|     _filteredList = List.from(_ad6List); | ||||
|     notifyListeners(); | ||||
|   } | ||||
| 
 | ||||
|   // Refresh data | ||||
|   Future<void> refreshData() async { | ||||
|     await getAllWithPagination(refresh: true); | ||||
|   } | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| List<Map<String, dynamic>> countryItems = []; | ||||
| 
 | ||||
|  Future<List<Map<String, dynamic>>>   getcountry() async { | ||||
| 
 | ||||
|       try { | ||||
|      final value = await repo.getcountry(); | ||||
|         countryItems =  (value as List) | ||||
|             .map((item) => item as Map<String, dynamic>) | ||||
|             .toList(); | ||||
| 
 | ||||
|    return countryItems; | ||||
|     } catch (e) { | ||||
|       throw Exception('Failed to get all: $e'); | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
| List<Map<String, dynamic>> dependentstateItems = []; | ||||
| 
 | ||||
|  Future<List<Map<String, dynamic>>>   getstateDependent(String name) async { | ||||
| 
 | ||||
|       try { | ||||
|      final value = await repo.getstateDependent(name); | ||||
|         dependentstateItems =  (value as List) | ||||
|             .map((item) => item as Map<String, dynamic>) | ||||
|             .toList(); | ||||
| 
 | ||||
|    return dependentstateItems; | ||||
|     } catch (e) { | ||||
|       throw Exception('Failed to get all Dependent Item: $e'); | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
| List<Map<String, dynamic>> dependentdistrictItems = []; | ||||
| 
 | ||||
|  Future<List<Map<String, dynamic>>>   getdistrictDependent(String name) async { | ||||
| 
 | ||||
|       try { | ||||
|      final value = await repo.getdistrictDependent(name); | ||||
|         dependentdistrictItems =  (value as List) | ||||
|             .map((item) => item as Map<String, dynamic>) | ||||
|             .toList(); | ||||
| 
 | ||||
|    return dependentdistrictItems; | ||||
|     } catch (e) { | ||||
|       throw Exception('Failed to get all Dependent Item: $e'); | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
| } | ||||
| @ -0,0 +1,84 @@ | ||||
| import 'dart:typed_data'; | ||||
| import 'package:dio/dio.dart'; | ||||
| import 'package:http_parser/http_parser.dart'; | ||||
| import '../../../../resources/api_constants.dart'; | ||||
| import '../../../../data/network/base_network_service.dart'; | ||||
| import '../../../../data/network/network_api_service.dart'; | ||||
| 
 | ||||
| class CountryApiService { | ||||
|   final String baseUrl = ApiConstants.baseUrl; | ||||
| 
 | ||||
|       final BaseNetworkService _helper = NetworkApiService(); | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|    Future<List<Map<String, dynamic>>> getEntities() async { | ||||
| 
 | ||||
|     try { | ||||
|       final response = await _helper.getGetApiResponse('$baseUrl/Country/Country'); | ||||
|       final entities = (response as List).cast<Map<String, dynamic>>(); | ||||
|       return entities; | ||||
|     } catch (e) { | ||||
|       throw Exception('Failed to get all entities: $e'); | ||||
|     } | ||||
|   } | ||||
| Future<List<Map<String, dynamic>>> getAllWithPagination( | ||||
|        int page, int size) async { | ||||
|     try { | ||||
|             final response = | ||||
|           await _helper.getGetApiResponse('$baseUrl/Country/Country/getall/page?page=$page&size=$size'); | ||||
|       final entities = | ||||
|           (response['content'] as List).cast<Map<String, dynamic>>(); | ||||
|       return entities; | ||||
|     } catch (e) { | ||||
|       throw Exception('Failed to get all without pagination: $e'); | ||||
|     } | ||||
|   } | ||||
|   Future<Map<String, dynamic>> createEntity( | ||||
|        Map<String, dynamic> entity) async { | ||||
|     try { | ||||
|             print("in post api$entity"); | ||||
|       final response = | ||||
|           await _helper.getPostApiResponse('$baseUrl/Country/Country', entity); | ||||
| 
 | ||||
|       print(entity); | ||||
| 
 | ||||
|       // Assuming the response is a Map<String, dynamic> | ||||
|       Map<String, dynamic> responseData = response; | ||||
| 
 | ||||
|       return responseData; | ||||
|     } catch (e) { | ||||
|       throw Exception('Failed to create entity: $e'); | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|   Future<void> updateEntity( int entityId, Map<String, dynamic> entity) async { | ||||
|     try { | ||||
|      await _helper.getPutApiResponse('$baseUrl/Country/Country/$entityId', | ||||
|       entity);                print(entity); | ||||
| 
 | ||||
|     } catch (e) { | ||||
|       throw Exception('Failed to update entity: $e'); | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
|   Future<void> deleteEntity( int entityId) async { | ||||
|     try { | ||||
|  await _helper.getDeleteApiResponse('$baseUrl/Country/Country/$entityId'); | ||||
|     } catch (e) { | ||||
|       throw Exception('Failed to delete entity: $e'); | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| } | ||||
| @ -0,0 +1,82 @@ | ||||
| // ignore_for_file: use_build_context_synchronously | ||||
| import 'dart:convert'; | ||||
| import 'package:flutter/material.dart'; | ||||
| import 'package:file_picker/file_picker.dart'; | ||||
| import 'package:image_picker/image_picker.dart'; | ||||
| import 'package:provider/provider.dart'; | ||||
| import '../Country_viewModel/Country_view_model_screen.dart'; | ||||
| import 'Country_fields.dart';import 'package:base_project/BuilderField/shared/ui/entity_screens.dart'; | ||||
| import '../../../../utils/image_constant.dart'; | ||||
| import '../../../../utils/size_utils.dart'; | ||||
| import '../../../../theme/app_style.dart'; | ||||
| import '../../../../widgets/app_bar/appbar_image.dart'; | ||||
| import '../../../../widgets/app_bar/appbar_title.dart'; | ||||
| import '../../../../widgets/app_bar/custom_app_bar.dart'; | ||||
| import '../../../../widgets/custom_button.dart'; | ||||
| import '../../../../widgets/custom_text_form_field.dart';  | ||||
| import '../../../../widgets/custom_dropdown_field.dart'; | ||||
| import 'dart:math'; | ||||
| import 'package:qr_flutter/qr_flutter.dart'; | ||||
| import 'package:barcode_widget/barcode_widget.dart'; | ||||
| import 'package:intl/intl.dart'; | ||||
|   | ||||
| import 'package:autocomplete_textfield/autocomplete_textfield.dart'; | ||||
| import 'package:http/http.dart' as http; | ||||
| import 'package:flutter/services.dart'; | ||||
| import 'package:image_picker/image_picker.dart'; | ||||
| import 'package:fluttertoast/fluttertoast.dart'; | ||||
| import '../../../../Reuseable/reusable_date_picker_field.dart'; | ||||
| import '../../../../Reuseable/reusable_date_time_picker_field.dart' | ||||
| ;import 'package:multi_select_flutter/multi_select_flutter.dart'; | ||||
| import 'package:just_audio/just_audio.dart'; | ||||
| import 'package:video_player/video_player.dart'; | ||||
| import 'package:google_fonts/google_fonts.dart'; | ||||
| import 'package:lottie/lottie.dart'; | ||||
| import '../../../../utils/toast_messages/toast_message_util.dart'; | ||||
| import 'dart:io'; | ||||
| import '../../../../Reuseable/reusable_text_field.dart'; | ||||
| import '../../../../Reuseable/reusable_dropdown_field.dart'; | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| class CountryCreateEntityScreen extends StatefulWidget { | ||||
|   const CountryCreateEntityScreen({super.key}); | ||||
| 
 | ||||
|   @override | ||||
|   _CountryCreateEntityScreenState createState() => _CountryCreateEntityScreenState(); | ||||
| } | ||||
| 
 | ||||
| class _CountryCreateEntityScreenState extends State<CountryCreateEntityScreen> { | ||||
| 
 | ||||
| final Map<String, dynamic> formData = {}; | ||||
|   final _formKey = GlobalKey<FormState>(); | ||||
|    | ||||
|   @override | ||||
|   Widget build(BuildContext context) { | ||||
|     return Consumer<CountryViewModelScreen>( | ||||
|       builder: (context, viewModel, child) { | ||||
|         return EntityCreateScreen( | ||||
|           fields: CountryFields.getFields(context), | ||||
|           onSubmit: (data) => _handleSubmit(data), | ||||
|           title: 'Country', | ||||
|           isLoading: viewModel.isLoading, | ||||
|           errorMessage: | ||||
|               viewModel.errorMessage.isNotEmpty ? viewModel.errorMessage : null, | ||||
|         ); | ||||
|       }, | ||||
|     ); | ||||
|   } | ||||
| 
 | ||||
|   Future<void> _handleSubmit(Map<String, dynamic> formData) async { | ||||
|     final provider = | ||||
|         Provider.of<CountryViewModelScreen>(context, listen: false); | ||||
|     final success = await provider.createEntity(formData); | ||||
| 
 | ||||
|     if (success && mounted) { | ||||
|       Navigator.pop(context); | ||||
|     } | ||||
|   } | ||||
| } | ||||
| @ -0,0 +1,90 @@ | ||||
| // ignore_for_file: use_build_context_synchronously | ||||
| import 'package:flutter/material.dart'; | ||||
| import 'package:provider/provider.dart'; | ||||
| import '../../../../BuilderField/shared/ui/entity_details.dart'; | ||||
| import '../Country_viewModel/Country_view_model_screen.dart'; | ||||
| import 'Country_update_entity_screen.dart'; | ||||
| 
 | ||||
| class CountryDetailsScreen extends StatefulWidget { | ||||
|   final Map<String, dynamic> entity; | ||||
| 
 | ||||
|   const CountryDetailsScreen({ | ||||
|     super.key, | ||||
|     required this.entity, | ||||
|   }); | ||||
| 
 | ||||
|   @override | ||||
|   State<CountryDetailsScreen> createState() => _CountryDetailsScreenState(); | ||||
| } | ||||
| 
 | ||||
| class _CountryDetailsScreenState extends State<CountryDetailsScreen> { | ||||
|   void _navigateToUpdateScreen(Map<String, dynamic> entity) { | ||||
|     Navigator.push( | ||||
|       context, | ||||
|       MaterialPageRoute( | ||||
|         builder: (context) => ChangeNotifierProvider( | ||||
|           create: (context) => CountryViewModelScreen(), | ||||
|           child: CountryUpdateEntityScreen(entity: entity), | ||||
|         ), | ||||
|       ), | ||||
|     ).then((_) { | ||||
|       // Refresh the details screen with updated data | ||||
|       setState(() {}); | ||||
|     }); | ||||
|   } | ||||
| 
 | ||||
|   void _showDeleteDialog(Map<String, dynamic> entity) { | ||||
|     showDialog( | ||||
|       context: context, | ||||
|       builder: (BuildContext context) { | ||||
|         return AlertDialog( | ||||
|           title: const Text('Confirm Deletion'), | ||||
|           content: const Text('Are you sure you want to delete this Country?'), | ||||
|           actions: [ | ||||
|             TextButton( | ||||
|               child: const Text('Cancel'), | ||||
|               onPressed: () { | ||||
|                 Navigator.of(context).pop(); | ||||
|               }, | ||||
|             ), | ||||
|             TextButton( | ||||
|               child: const Text('Delete'), | ||||
|               onPressed: () async { | ||||
|                 Navigator.of(context).pop(); | ||||
|                 final vm = | ||||
|                     Provider.of<CountryViewModelScreen>(context, listen: false); | ||||
|                 final success = await vm.deleteEntity(entity['id']); | ||||
|                 if (success && mounted) { | ||||
|                   Navigator.pop(context); // Go back to list | ||||
|                 } | ||||
|               }, | ||||
|             ), | ||||
|           ], | ||||
|         ); | ||||
|       }, | ||||
|     ); | ||||
|   } | ||||
| 
 | ||||
|   @override | ||||
|   Widget build(BuildContext context) { | ||||
|     return Consumer<CountryViewModelScreen>( | ||||
|       builder: (context, viewModel, child) { | ||||
|         return EntityDetails( | ||||
|           entity: widget.entity, | ||||
|           onEdit: (entity) => _navigateToUpdateScreen(entity), | ||||
|           onDelete: (entity) => _showDeleteDialog(entity), | ||||
|           title: 'Country', | ||||
|           displayFields: [ | ||||
|   {'key': 'name', 'label': 'Name', 'type': 'text'}, | ||||
| 
 | ||||
|   {'key': 'description', 'label': 'Description', 'type': 'textarea'}, | ||||
| 
 | ||||
|   {'key': 'active', 'label': 'Active', 'type': 'toggle_switch'}, | ||||
| 
 | ||||
|           ], | ||||
|           isLoading: viewModel.isLoading, | ||||
|         ); | ||||
|       }, | ||||
|     ); | ||||
|   } | ||||
| } | ||||
| @ -0,0 +1,150 @@ | ||||
| // ignore_for_file: use_build_context_synchronously | ||||
| import 'package:flutter/material.dart'; | ||||
| import 'package:intl/intl.dart'; | ||||
| import 'package:base_project/BuilderField/shared/ui/entity_list.dart'; | ||||
| import 'Country_create_entity_screen.dart'; | ||||
| import 'Country_update_entity_screen.dart'; | ||||
| import '../Country_viewModel/Country_view_model_screen.dart'; | ||||
| import 'Country_details_screen.dart';import 'package:flutter/services.dart'; | ||||
| import 'package:speech_to_text/speech_to_text.dart' as stt; | ||||
| import '../../../../theme/app_style.dart'; | ||||
| import '../../../../utils/size_utils.dart'; | ||||
| import '../../../../widgets/custom_icon_button.dart'; | ||||
| import '../../../../utils/image_constant.dart'; | ||||
| import '../../../../widgets/app_bar/appbar_image.dart'; | ||||
| import '../../../../widgets/app_bar/appbar_title.dart'; | ||||
| import '../../../../widgets/app_bar/custom_app_bar.dart'; | ||||
| import '../../../../theme/app_decoration.dart'; | ||||
| import 'package:multi_select_flutter/multi_select_flutter.dart'; | ||||
| import '../../../../Reuseable/reusable_text_field.dart'; | ||||
| import 'package:provider/provider.dart'; | ||||
| import '../../../../utils/toast_messages/toast_message_util.dart'; | ||||
| import 'package:fluttertoast/fluttertoast.dart'; | ||||
| 
 | ||||
| class Country_entity_list_screen extends StatefulWidget { | ||||
|   static const String routeName = '/entity-list'; | ||||
| 
 | ||||
|   @override | ||||
|   _Country_entity_list_screenState createState() => _Country_entity_list_screenState(); | ||||
| } | ||||
| 
 | ||||
| class _Country_entity_list_screenState extends State<Country_entity_list_screen> { | ||||
|   @override | ||||
|   void initState() { | ||||
|     super.initState(); | ||||
|     _loadData(); | ||||
|   } | ||||
| 
 | ||||
|   void _loadData() { | ||||
|     WidgetsBinding.instance.addPostFrameCallback((_) { | ||||
|       if (mounted) { | ||||
|         final vm = Provider.of<CountryViewModelScreen>(context, listen: false); | ||||
|         vm.getAllWithPagination(refresh: true); | ||||
|       } | ||||
|     }); | ||||
|   } | ||||
| 
 | ||||
|   void _navigateToCreateScreen() { | ||||
|     Navigator.push( | ||||
|       context, | ||||
|       MaterialPageRoute( | ||||
|         builder: (context) => ChangeNotifierProvider( | ||||
|           create: (context) => CountryViewModelScreen(), | ||||
|           child: const CountryCreateEntityScreen(), | ||||
|         ), | ||||
|       ), | ||||
|     ).then((_) { | ||||
|       final vm = Provider.of<CountryViewModelScreen>(context, listen: false); | ||||
|       vm.refreshData(); | ||||
|     }); | ||||
|   } | ||||
| 
 | ||||
|   void _navigateToUpdateScreen(Map<String, dynamic> entity) { | ||||
|     Navigator.push( | ||||
|       context, | ||||
|       MaterialPageRoute( | ||||
|         builder: (context) => ChangeNotifierProvider( | ||||
|           create: (context) => CountryViewModelScreen(), | ||||
|           child: CountryUpdateEntityScreen(entity: entity), | ||||
|         ), | ||||
|       ), | ||||
|     ).then((_) { | ||||
|       final vm = Provider.of<CountryViewModelScreen>(context, listen: false); | ||||
|       vm.refreshData(); | ||||
|     }); | ||||
|   } | ||||
| 
 | ||||
|   void _navigateToDetailsScreen(Map<String, dynamic> entity) { | ||||
|     Navigator.push( | ||||
|       context, | ||||
|       MaterialPageRoute( | ||||
|         builder: (context) => ChangeNotifierProvider( | ||||
|           create: (context) => CountryViewModelScreen(), | ||||
|           child: CountryDetailsScreen(entity: entity), | ||||
|         ), | ||||
|       ), | ||||
|     ); | ||||
|   } | ||||
| 
 | ||||
|   void _showDeleteDialog(Map<String, dynamic> entity) { | ||||
|  final parentContext = context;  | ||||
|     showDialog( | ||||
|       context: context, | ||||
|       builder: (BuildContext context) { | ||||
|         return AlertDialog( | ||||
|           title: const Text('Confirm Deletion'), | ||||
|           content: const Text('Are you sure you want to delete this Country?'), | ||||
|           actions: [ | ||||
|             TextButton( | ||||
|               child: const Text('Cancel'), | ||||
|               onPressed: () { | ||||
|                 Navigator.of(context).pop(); | ||||
|               }, | ||||
|             ), | ||||
|             TextButton( | ||||
|               child: const Text('Delete'), | ||||
|               onPressed: () async { | ||||
|                 Navigator.of(context).pop(); | ||||
|                 final vm = | ||||
|                     Provider.of<CountryViewModelScreen>(parentContext, listen: false); | ||||
|                 await vm.deleteEntity(entity['id']); | ||||
|               }, | ||||
|             ), | ||||
|           ], | ||||
|         ); | ||||
|       }, | ||||
|     ); | ||||
|   } | ||||
| 
 | ||||
|   @override | ||||
|   Widget build(BuildContext context) { | ||||
|     return Consumer<CountryViewModelScreen>( | ||||
|       builder: (context, viewModel, child) { | ||||
|         return EntityList( | ||||
|           entities: viewModel.filteredList, | ||||
|           isLoading: viewModel.isLoading, | ||||
|           errorMessage: | ||||
|               viewModel.errorMessage.isNotEmpty ? viewModel.errorMessage : null, | ||||
|           hasMoreData: viewModel.hasMoreData, | ||||
|           searchQuery: viewModel.searchQuery, | ||||
|           onSearchChanged: (query) => viewModel.searchcountry(query), | ||||
|           onEdit: (entity) => _navigateToUpdateScreen(entity), | ||||
|           onDelete: (entity) => _showDeleteDialog(entity), | ||||
|           onTap: (entity) => _navigateToDetailsScreen(entity), | ||||
|           onRefresh: () => viewModel.refreshData(), | ||||
|           onLoadMore: () => viewModel.getAllWithPagination(), | ||||
|           title: 'Country', | ||||
|           onAddNew: _navigateToCreateScreen, | ||||
|           displayFields: [ | ||||
|   {'key': 'name', 'label': 'Name', 'type': 'text'}, | ||||
| 
 | ||||
|   {'key': 'description', 'label': 'Description', 'type': 'textarea'}, | ||||
| 
 | ||||
|   {'key': 'active', 'label': 'Active', 'type': 'toggle_switch'}, | ||||
| 
 | ||||
|           ], | ||||
|         ); | ||||
|       }, | ||||
|     ); | ||||
|   } | ||||
| } | ||||
| @ -0,0 +1,76 @@ | ||||
| import 'package:base_project/BuilderField/shared/fields/number_field.dart'; | ||||
| import 'package:base_project/BuilderField/shared/fields/password_field.dart'; | ||||
| import 'package:base_project/BuilderField/shared/fields/phone_field.dart'; | ||||
| import 'package:base_project/BuilderField/shared/fields/custom_text_field.dart'; | ||||
| 
 | ||||
| import '../../../../BuilderField/shared/fields/base_field.dart'; | ||||
| 
 | ||||
| import '../../../../BuilderField/shared/fields/date_field.dart'; | ||||
| import '../../../../BuilderField/shared/fields/datetime_field.dart'; | ||||
| import '../../../../BuilderField/shared/fields/email_field.dart'; | ||||
| import 'package:base_project/BuilderField/shared/fields/url_field.dart'; | ||||
| import 'package:flutter/material.dart'; | ||||
| import 'package:provider/provider.dart'; | ||||
| 
 | ||||
| import '../../../../BuilderField/shared/fields/custom_text_field.dart' as shared_text; | ||||
| import '../../../../BuilderField/shared/fields/one_to_one_relation_field.dart'; | ||||
| import '../../../../BuilderField/shared/fields/calculated_field.dart'; | ||||
| import '../../../../BuilderField/shared/fields/one_to_many_field.dart'; | ||||
| import '../../../../BuilderField/shared/fields/value_list_picker_field.dart'; | ||||
| import '../../../../BuilderField/shared/fields/captcha_field.dart'; | ||||
| import '../../../../BuilderField/shared/fields/switch_field.dart'; | ||||
| import '../../../../BuilderField/shared/fields/url_field.dart'; | ||||
| 
 | ||||
| import '../../../../BuilderField/shared/fields/audio_upload_field.dart'; | ||||
| import '../../../../BuilderField/shared/fields/checkbox_field.dart'; | ||||
| import '../../../../BuilderField/shared/fields/file_upload_field.dart'; | ||||
| import '../../../../BuilderField/shared/fields/image_upload_field.dart'; | ||||
| import '../../../../BuilderField/shared/fields/radio_field.dart'; | ||||
| import '../../../../BuilderField/shared/fields/video_upload_field.dart'; | ||||
| 
 | ||||
| import '../../../../BuilderField/shared/fields/autocomplete_dropdown_field.dart'; | ||||
| import '../../../../BuilderField/shared/fields/autocomplete_multiselect_field.dart'; | ||||
| import '../../../../BuilderField/shared/fields/one_to_one_relation_field.dart'; | ||||
| import '../../../../BuilderField/shared/fields/data_grid_field.dart'; | ||||
| import '../../../../BuilderField/shared/fields/dropdown_field.dart'; | ||||
| import '../../../../BuilderField/shared/fields/dynamic_dropdown_field.dart'; | ||||
| import '../../../../BuilderField/shared/fields/dynamic_multiselect_dropdown_field.dart'; | ||||
| import '../../../../BuilderField/shared/fields/static_multiselect_field.dart'; | ||||
| import '../../../../BuilderField/shared/fields/currency_field.dart'; | ||||
| import '../../../../BuilderField/shared/fields/field_group_field.dart'; | ||||
| import '../../../../BuilderField/shared/fields/qr_code_field.dart'; | ||||
| import '../../../../BuilderField/shared/fields/barcode_field.dart'; | ||||
| import '../../../../BuilderField/shared/fields/dependent_dropdown_field.dart'; | ||||
|  import '../Country_viewModel/Country_view_model_screen.dart';/// Field definitions for Country entity | ||||
| /// This defines the structure and validation for Country forms | ||||
| class CountryFields { | ||||
|   /// Get field definitions for Country entity | ||||
|   static List<BaseField> getFields(BuildContext context) { | ||||
|     final viewModel = | ||||
|         Provider.of<CountryViewModelScreen>(context, listen: false); | ||||
|     return [ | ||||
|       // Basic Information | ||||
|  CustomTextField( | ||||
|         fieldKey: 'name', | ||||
|         label: 'Name', | ||||
|         hint: 'Enter Name', | ||||
|         isRequired: true, | ||||
|         maxLength: 50, | ||||
|       ), | ||||
| 
 | ||||
| CustomTextField( | ||||
|         fieldKey: 'description', | ||||
|         label: 'Description', | ||||
|         hint: 'Enter Description', | ||||
|         isRequired: false, | ||||
|         maxLength: 1000, | ||||
|       ), | ||||
| 
 | ||||
|  SwitchField( | ||||
|         fieldKey: 'active', | ||||
|         label: 'Active', | ||||
|       ), | ||||
| 
 | ||||
|     ]; | ||||
|   } | ||||
| } | ||||
| @ -0,0 +1,77 @@ | ||||
| // ignore_for_file: use_build_context_synchronously | ||||
| import 'dart:convert'; | ||||
| import 'package:provider/provider.dart'; | ||||
| import '../Country_viewModel/Country_view_model_screen.dart'; | ||||
| import 'package:base_project/BuilderField/shared/ui/entity_screens.dart'; | ||||
| import 'Country_fields.dart';import '../../../../utils/image_constant.dart'; | ||||
| import '../../../../utils/size_utils.dart'; | ||||
| import '../../../../theme/app_style.dart'; | ||||
| import '../../../../widgets/app_bar/appbar_image.dart'; | ||||
| import '../../../../widgets/app_bar/appbar_title.dart'; | ||||
| import '../../../../widgets/app_bar/custom_app_bar.dart'; | ||||
| import 'package:barcode_widget/barcode_widget.dart'; | ||||
| import 'package:fluttertoast/fluttertoast.dart'; | ||||
| import '../../../../widgets/custom_button.dart'; | ||||
| import '../../../../widgets/custom_text_form_field.dart'; | ||||
| import 'package:flutter/material.dart'; | ||||
| import 'package:autocomplete_textfield/autocomplete_textfield.dart'; | ||||
| import 'package:qr_flutter/qr_flutter.dart'; | ||||
| import 'package:intl/intl.dart'; | ||||
| 
 | ||||
| import 'dart:math'; | ||||
| import '../../../../Reuseable/reusable_text_field.dart'; | ||||
| import '../../../../Reuseable/reusable_date_picker_field.dart'; | ||||
| import '../../../../Reuseable/reusable_date_time_picker_field.dart'; | ||||
| import '../../../../Reuseable/reusable_dropdown_field.dart'; | ||||
| import 'package:flutter/services.dart'; | ||||
| class CountryUpdateEntityScreen extends StatefulWidget { | ||||
|     final Map<String, dynamic> entity; | ||||
| 
 | ||||
| 
 | ||||
|   CountryUpdateEntityScreen({required this.entity}); | ||||
| 
 | ||||
|   @override | ||||
|   _CountryUpdateEntityScreenState createState() => _CountryUpdateEntityScreenState(); | ||||
| } | ||||
| 
 | ||||
| class _CountryUpdateEntityScreenState extends State<CountryUpdateEntityScreen> { | ||||
|   final _formKey = GlobalKey<FormState>(); | ||||
| 
 | ||||
| @override | ||||
|   Widget build(BuildContext context) { | ||||
|     return Consumer<CountryViewModelScreen>( | ||||
|       builder: (context, viewModel, child) { | ||||
| // Start with all fields, then remove upload fields (generic filter by keys) | ||||
|         final Set<String> hiddenKeys = {  | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|  }; | ||||
|         final fields = CountryFields.getFields(context) | ||||
|             .where((f) => !hiddenKeys.contains(f.fieldKey)) | ||||
|             .toList();        return EntityUpdateScreen( | ||||
|           fields: fields, | ||||
|           initialData: widget.entity, | ||||
|           onSubmit: (data) => _handleSubmit(data), | ||||
|           title: 'Country', | ||||
|           isLoading: viewModel.isLoading, | ||||
|           errorMessage: | ||||
|               viewModel.errorMessage.isNotEmpty ? viewModel.errorMessage : null, | ||||
|         ); | ||||
|       }, | ||||
|     ); | ||||
|   } | ||||
| 
 | ||||
|   Future<void> _handleSubmit(Map<String, dynamic> formData) async { | ||||
|     final provider = | ||||
|         Provider.of<CountryViewModelScreen>(context, listen: false); | ||||
|     final success = await provider.updateEntity(widget.entity['id'], formData); | ||||
| 
 | ||||
|     if (success && mounted) { | ||||
|       Navigator.pop(context); | ||||
|     } | ||||
|   } | ||||
| } | ||||
| @ -0,0 +1,95 @@ | ||||
| import 'package:dio/dio.dart'; | ||||
| import '../../../../data/network/base_network_service.dart'; | ||||
| import '../../../../data/network/network_api_service.dart'; | ||||
| import '../../../../resources/api_constants.dart'; | ||||
| import 'package:base_project/data/response/api_response.dart'; | ||||
| 
 | ||||
| class CountryRepoScreen { | ||||
| 
 | ||||
|   final String baseUrl = ApiConstants.baseUrl; | ||||
|   final BaseNetworkService _helper = NetworkApiService(); | ||||
|   final String _endpointPath = '/Country/Country'; | ||||
| 
 | ||||
|   Future<ApiResponse<List<Map<String, dynamic>>>> getEntities() async { | ||||
|     try { | ||||
|       final response = | ||||
|           await _helper.getGetApiResponse('$baseUrl$_endpointPath'); | ||||
|       print('Response received: $response'); | ||||
|       List<Map<String, dynamic>> entities = const []; | ||||
|       if (response is List) { | ||||
|         entities = response | ||||
|             .whereType<Map>() | ||||
|             .map((e) => Map<String, dynamic>.from(e as Map)) | ||||
|             .toList(); | ||||
|       } else if (response is Map<String, dynamic>) { | ||||
|         final dynamic content = response['content']; | ||||
|         if (content is List) { | ||||
|           entities = content | ||||
|               .whereType<Map>() | ||||
|               .map((e) => Map<String, dynamic>.from(e as Map)) | ||||
|               .toList(); | ||||
|         } | ||||
|       } | ||||
|       return ApiResponse.success(entities); | ||||
|     } catch (e) { | ||||
|       print(' error got $e'); | ||||
|       return ApiResponse.error('Failed to get all entities: $e'); | ||||
|     } | ||||
|   }  | ||||
| 
 | ||||
|   Future<ApiResponse<List<Map<String, dynamic>>>> getAllWithPagination( | ||||
|       int page, int size) async { | ||||
|     try { | ||||
|       final response = await _helper.getGetApiResponse( | ||||
|           '$baseUrl$_endpointPath/getall/page?page=$page&size=$size'); | ||||
| 
 | ||||
|       if (response is Map<String, dynamic> && response['content'] is List) { | ||||
|         final List<Map<String, dynamic>> entities = | ||||
|             (response['content'] as List).cast<Map<String, dynamic>>().toList(); | ||||
|         return ApiResponse.success(entities); | ||||
|       } else { | ||||
|         return ApiResponse.error('Invalid response format'); | ||||
|       } | ||||
|     } catch (e) { | ||||
|       return ApiResponse.error('Failed to get all without pagination: $e'); | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
|   Future<ApiResponse<Map<String, dynamic>>> createEntity( | ||||
|       Map<String, dynamic> entity) async { | ||||
|     try { | ||||
|       print("in post api$entity"); | ||||
|       final response = | ||||
|           await _helper.getPostApiResponse('$baseUrl$_endpointPath', entity); | ||||
|       return ApiResponse.success(response as Map<String, dynamic>); | ||||
|     } catch (e) { | ||||
|       return ApiResponse.error('Failed to create entity: $e'); | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
|   Future<ApiResponse<Map<String, dynamic>>> updateEntity( | ||||
|       int entityId, Map<String, dynamic> entity) async { | ||||
|     try { | ||||
|       final response = await _helper.getPutApiResponse( | ||||
|           '$baseUrl$_endpointPath/$entityId', entity); | ||||
|       return ApiResponse.success(response as Map<String, dynamic>); | ||||
|     } catch (e) { | ||||
|       return ApiResponse.error('Failed to update entity: $e'); | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
|   Future<ApiResponse<void>> deleteEntity(int entityId) async { | ||||
|     try { | ||||
|       await _helper.getDeleteApiResponse('$baseUrl$_endpointPath/$entityId'); | ||||
|       return ApiResponse.success(null); | ||||
|     } catch (e) { | ||||
|       return ApiResponse.error('Failed to delete entity: $e'); | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| } | ||||
| @ -0,0 +1,305 @@ | ||||
| import 'package:base_project/data/response/status.dart'; | ||||
| import 'dart:typed_data'; | ||||
| import 'package:dio/dio.dart'; | ||||
| import 'package:http_parser/http_parser.dart'; | ||||
| import '../../../../utils/toast_messages/toast_message_util.dart'; | ||||
| import '../../../../BuilderField/shared/utils/entity_field_store.dart'; | ||||
| import 'package:flutter/material.dart'; | ||||
| import '../Country_Repo/Country_repo_screen.dart'; | ||||
| 
 | ||||
| class CountryViewModelScreen extends ChangeNotifier{ | ||||
|   final CountryRepoScreen repo = CountryRepoScreen(); | ||||
| 
 | ||||
|   | ||||
|   // State variables | ||||
|   List<Map<String, dynamic>> _countryList = []; | ||||
|   List<Map<String, dynamic>> _filteredList = []; | ||||
|   bool _isLoading = false; | ||||
|   String _errorMessage = ''; | ||||
|   int _currentPage = 0; | ||||
|   int _pageSize = 10; | ||||
|   bool _hasMoreData = true; | ||||
|   String _searchQuery = ''; | ||||
| 
 | ||||
|   // Getters | ||||
|   List<Map<String, dynamic>> get countryList => _countryList; | ||||
|   List<Map<String, dynamic>> get filteredList => _filteredList; | ||||
|   bool get isLoading => _isLoading; | ||||
|   String get errorMessage => _errorMessage; | ||||
|   bool get hasMoreData => _hasMoreData; | ||||
|   String get searchQuery => _searchQuery; | ||||
| 
 | ||||
|   // Set loading state | ||||
|   void _setLoading(bool loading) { | ||||
|     _isLoading = loading; | ||||
|     notifyListeners(); | ||||
|   } | ||||
| 
 | ||||
|   // Set error message | ||||
|   void _setError(String error) { | ||||
|     _errorMessage = error; | ||||
|     notifyListeners(); | ||||
|   } | ||||
| 
 | ||||
|   // Clear error | ||||
|   void clearError() { | ||||
|     _errorMessage = ''; | ||||
|     notifyListeners(); | ||||
|   } | ||||
| 
 | ||||
|   // Get country list | ||||
|   Future<void> getEntities() async { | ||||
|     _setLoading(true); | ||||
|     _setError(''); | ||||
| 
 | ||||
|     try { | ||||
|       final response = await repo.getEntities(); | ||||
| 
 | ||||
|       if (response.status == Status.SUCCESS) { | ||||
|         _countryList = response.data ?? []; | ||||
|         _filteredList = List.from(_countryList); | ||||
|         _currentPage = 0; | ||||
|         _hasMoreData = true; | ||||
|       } else { | ||||
|         _setError(response.message ?? 'Failed to fetch country list'); | ||||
|       } | ||||
|     } catch (e) { | ||||
|       _setError('Failed to fetch country list: $e'); | ||||
|     } finally { | ||||
|       _setLoading(false); | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
|   // Get country list with pagination | ||||
|   Future<void> getAllWithPagination({bool refresh = false}) async { | ||||
|     if (refresh) { | ||||
|       _currentPage = 0; | ||||
|       _countryList.clear(); | ||||
|       _filteredList.clear(); | ||||
|       _hasMoreData = true; | ||||
|     } | ||||
| 
 | ||||
|     if (!_hasMoreData || _isLoading) return; | ||||
| 
 | ||||
|     _setLoading(true); | ||||
|     _setError(''); | ||||
| 
 | ||||
|     try { | ||||
|       final response = await repo.getAllWithPagination(_currentPage, _pageSize); | ||||
| 
 | ||||
|       if (response.status == Status.SUCCESS) { | ||||
|         final newItems = response.data ?? []; | ||||
| 
 | ||||
|         if (refresh) { | ||||
|           _countryList = newItems; | ||||
|         } else { | ||||
|           _countryList.addAll(newItems); | ||||
|         } | ||||
| 
 | ||||
|         _filteredList = List.from(_countryList); | ||||
|         _currentPage++; | ||||
| 
 | ||||
|         // Check if we have more data | ||||
|         _hasMoreData = newItems.length == _pageSize; | ||||
|       } else { | ||||
|         _setError(response.message ?? 'Failed to fetch Country list'); | ||||
|       } | ||||
|     } catch (e) { | ||||
|       _setError('Failed to fetch country list: $e'); | ||||
|     } finally { | ||||
|       _setLoading(false); | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|   // Create Country | ||||
|   Future<bool> createEntity(Map<String, dynamic> entity) async { | ||||
|     _setLoading(true); | ||||
|     _setError(''); | ||||
| 
 | ||||
|     try { | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|       final response = await repo.createEntity(entity); | ||||
| 
 | ||||
|       if (response.status == Status.SUCCESS) { | ||||
| // Get the response ID for image upload | ||||
| 
 | ||||
|         final responseId = response.data!['id'].toString(); | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|         ToastMessageUtil.showToast( | ||||
|           message: 'country created successfully', | ||||
|           toastType: ToastType.success, | ||||
|         ); | ||||
| 
 | ||||
|         // Refresh the list | ||||
|         await getEntities(); | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|         return true; | ||||
|       } else { | ||||
|         _setError(response.message ?? 'Failed to create Country'); | ||||
|         ToastMessageUtil.showToast( | ||||
|           message: response.message ?? 'Failed to create Country', | ||||
|           toastType: ToastType.error, | ||||
|         ); | ||||
|         return false; | ||||
|       } | ||||
|     } catch (e) { | ||||
|       _setError('Failed to create country: $e'); | ||||
|       ToastMessageUtil.showToast( | ||||
|         message: 'Failed to create Country: $e', | ||||
|         toastType: ToastType.error, | ||||
|       ); | ||||
|       return false; | ||||
|     } finally { | ||||
|       _setLoading(false); | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
|   // Update country | ||||
|   Future<bool> updateEntity(int id, Map<String, dynamic> entity) async { | ||||
|     _setLoading(true); | ||||
|     _setError(''); | ||||
| 
 | ||||
|     try { | ||||
|       final response = await repo.updateEntity(id, entity); | ||||
| 
 | ||||
|       if (response.status == Status.SUCCESS) { | ||||
|         ToastMessageUtil.showToast( | ||||
|           message: 'Country updated successfully', | ||||
|           toastType: ToastType.success, | ||||
|         ); | ||||
| 
 | ||||
|         // Update the item in the list | ||||
|         final index = _countryList.indexWhere((item) => item['id'] == id); | ||||
|         if (index != -1) { | ||||
|           _countryList[index] = response.data!; | ||||
|           _filteredList = List.from(_countryList); | ||||
|           notifyListeners(); | ||||
|         } | ||||
|         return true; | ||||
|       } else { | ||||
|         _setError(response.message ?? 'Failed to update Country'); | ||||
|         ToastMessageUtil.showToast( | ||||
|           message: response.message ?? 'Failed to update Country', | ||||
|           toastType: ToastType.error, | ||||
|         ); | ||||
|         return false; | ||||
|       } | ||||
|     } catch (e) { | ||||
|       _setError('Failed to update country: $e'); | ||||
|       ToastMessageUtil.showToast( | ||||
|         message: 'Failed to update Country: $e', | ||||
|         toastType: ToastType.error, | ||||
|       ); | ||||
|       return false; | ||||
|     } finally { | ||||
|       _setLoading(false); | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
|   // Delete country | ||||
|   Future<bool> deleteEntity(int id) async { | ||||
|     _setLoading(true); | ||||
|     _setError(''); | ||||
| 
 | ||||
|     try { | ||||
|       final response = await repo.deleteEntity(id); | ||||
| 
 | ||||
|       if (response.status == Status.SUCCESS) { | ||||
|         ToastMessageUtil.showToast( | ||||
|           message: 'Country deleted successfully', | ||||
|           toastType: ToastType.success, | ||||
|         ); | ||||
| 
 | ||||
|         // Remove the item from the list | ||||
|         _countryList.removeWhere((item) => item['id'] == id); | ||||
|         _filteredList = List.from(_countryList); | ||||
|         notifyListeners(); | ||||
|         return true; | ||||
|       } else { | ||||
|         _setError(response.message ?? 'Failed to delete Country'); | ||||
|         ToastMessageUtil.showToast( | ||||
|           message: response.message ?? 'Failed to delete Country', | ||||
|           toastType: ToastType.error, | ||||
|         ); | ||||
|         return false; | ||||
|       } | ||||
|     } catch (e) { | ||||
|       _setError('Failed to delete country: $e'); | ||||
|       ToastMessageUtil.showToast( | ||||
|         message: 'Failed to delete Country: $e', | ||||
|         toastType: ToastType.error, | ||||
|       ); | ||||
|       return false; | ||||
|     } finally { | ||||
|       _setLoading(false); | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
|   // Search country | ||||
|   void searchcountry(String query) { | ||||
|     _searchQuery = query; | ||||
| 
 | ||||
|     if (query.isEmpty) { | ||||
|       _filteredList = List.from(_countryList); | ||||
|     } else { | ||||
|       _filteredList = _countryList.where((item) { | ||||
|         return | ||||
| 
 | ||||
|               | ||||
| (item['name']?.toString().toLowerCase().contains(query.toLowerCase()) ??false) || | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|               | ||||
| (item['description']?.toString().toLowerCase().contains(query.toLowerCase()) ??false) || | ||||
| 
 | ||||
| 
 | ||||
| (item['active']?.toString().toLowerCase().contains(query.toLowerCase()) ??false)  | ||||
| 
 | ||||
| 
 | ||||
| ; | ||||
|       }).toList(); | ||||
|     } | ||||
|     notifyListeners(); | ||||
|   } | ||||
| 
 | ||||
|   // Clear search | ||||
|   void clearSearch() { | ||||
|     _searchQuery = ''; | ||||
|     _filteredList = List.from(_countryList); | ||||
|     notifyListeners(); | ||||
|   } | ||||
| 
 | ||||
|   // Refresh data | ||||
|   Future<void> refreshData() async { | ||||
|     await getAllWithPagination(refresh: true); | ||||
|   } | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| } | ||||
| @ -0,0 +1,88 @@ | ||||
| import 'dart:typed_data'; | ||||
| import 'package:dio/dio.dart'; | ||||
| import 'package:http_parser/http_parser.dart'; | ||||
| import '../../../../resources/api_constants.dart'; | ||||
| import '../../../../data/network/base_network_service.dart'; | ||||
| import '../../../../data/network/network_api_service.dart'; | ||||
| 
 | ||||
| class DistrictApiService { | ||||
|   final String baseUrl = ApiConstants.baseUrl; | ||||
| 
 | ||||
|       final BaseNetworkService _helper = NetworkApiService(); | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|    Future<List<Map<String, dynamic>>> getEntities() async { | ||||
| 
 | ||||
|     try { | ||||
|       final response = await _helper.getGetApiResponse('$baseUrl/District/District'); | ||||
|       final entities = (response as List).cast<Map<String, dynamic>>(); | ||||
|       return entities; | ||||
|     } catch (e) { | ||||
|       throw Exception('Failed to get all entities: $e'); | ||||
|     } | ||||
|   } | ||||
| Future<List<Map<String, dynamic>>> getAllWithPagination( | ||||
|        int page, int size) async { | ||||
|     try { | ||||
|             final response = | ||||
|           await _helper.getGetApiResponse('$baseUrl/District/District/getall/page?page=$page&size=$size'); | ||||
|       final entities = | ||||
|           (response['content'] as List).cast<Map<String, dynamic>>(); | ||||
|       return entities; | ||||
|     } catch (e) { | ||||
|       throw Exception('Failed to get all without pagination: $e'); | ||||
|     } | ||||
|   } | ||||
|   Future<Map<String, dynamic>> createEntity( | ||||
|        Map<String, dynamic> entity) async { | ||||
|     try { | ||||
|             print("in post api$entity"); | ||||
|       final response = | ||||
|           await _helper.getPostApiResponse('$baseUrl/District/District', entity); | ||||
| 
 | ||||
|       print(entity); | ||||
| 
 | ||||
|       // Assuming the response is a Map<String, dynamic> | ||||
|       Map<String, dynamic> responseData = response; | ||||
| 
 | ||||
|       return responseData; | ||||
|     } catch (e) { | ||||
|       throw Exception('Failed to create entity: $e'); | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|   Future<void> updateEntity( int entityId, Map<String, dynamic> entity) async { | ||||
|     try { | ||||
|      await _helper.getPutApiResponse('$baseUrl/District/District/$entityId', | ||||
|       entity);                print(entity); | ||||
| 
 | ||||
|     } catch (e) { | ||||
|       throw Exception('Failed to update entity: $e'); | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
|   Future<void> deleteEntity( int entityId) async { | ||||
|     try { | ||||
|  await _helper.getDeleteApiResponse('$baseUrl/District/District/$entityId'); | ||||
|     } catch (e) { | ||||
|       throw Exception('Failed to delete entity: $e'); | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| } | ||||
| @ -0,0 +1,84 @@ | ||||
| // ignore_for_file: use_build_context_synchronously | ||||
| import 'dart:convert'; | ||||
| import 'package:flutter/material.dart'; | ||||
| import 'package:file_picker/file_picker.dart'; | ||||
| import 'package:image_picker/image_picker.dart'; | ||||
| import 'package:provider/provider.dart'; | ||||
| import '../District_viewModel/District_view_model_screen.dart'; | ||||
| import 'District_fields.dart';import 'package:base_project/BuilderField/shared/ui/entity_screens.dart'; | ||||
| import '../../../../utils/image_constant.dart'; | ||||
| import '../../../../utils/size_utils.dart'; | ||||
| import '../../../../theme/app_style.dart'; | ||||
| import '../../../../widgets/app_bar/appbar_image.dart'; | ||||
| import '../../../../widgets/app_bar/appbar_title.dart'; | ||||
| import '../../../../widgets/app_bar/custom_app_bar.dart'; | ||||
| import '../../../../widgets/custom_button.dart'; | ||||
| import '../../../../widgets/custom_text_form_field.dart';  | ||||
| import '../../../../widgets/custom_dropdown_field.dart'; | ||||
| import 'dart:math'; | ||||
| import 'package:qr_flutter/qr_flutter.dart'; | ||||
| import 'package:barcode_widget/barcode_widget.dart'; | ||||
| import 'package:intl/intl.dart'; | ||||
|   | ||||
| import 'package:autocomplete_textfield/autocomplete_textfield.dart'; | ||||
| import 'package:http/http.dart' as http; | ||||
| import 'package:flutter/services.dart'; | ||||
| import 'package:image_picker/image_picker.dart'; | ||||
| import 'package:fluttertoast/fluttertoast.dart'; | ||||
| import '../../../../Reuseable/reusable_date_picker_field.dart'; | ||||
| import '../../../../Reuseable/reusable_date_time_picker_field.dart' | ||||
| ;import 'package:multi_select_flutter/multi_select_flutter.dart'; | ||||
| import 'package:just_audio/just_audio.dart'; | ||||
| import 'package:video_player/video_player.dart'; | ||||
| import 'package:google_fonts/google_fonts.dart'; | ||||
| import 'package:lottie/lottie.dart'; | ||||
| import '../../../../utils/toast_messages/toast_message_util.dart'; | ||||
| import 'dart:io'; | ||||
| import '../../../../Reuseable/reusable_text_field.dart'; | ||||
| import '../../../../Reuseable/reusable_dropdown_field.dart'; | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| class DistrictCreateEntityScreen extends StatefulWidget { | ||||
|   const DistrictCreateEntityScreen({super.key}); | ||||
| 
 | ||||
|   @override | ||||
|   _DistrictCreateEntityScreenState createState() => _DistrictCreateEntityScreenState(); | ||||
| } | ||||
| 
 | ||||
| class _DistrictCreateEntityScreenState extends State<DistrictCreateEntityScreen> { | ||||
| 
 | ||||
| final Map<String, dynamic> formData = {}; | ||||
|   final _formKey = GlobalKey<FormState>(); | ||||
|    | ||||
|   @override | ||||
|   Widget build(BuildContext context) { | ||||
|     return Consumer<DistrictViewModelScreen>( | ||||
|       builder: (context, viewModel, child) { | ||||
|         return EntityCreateScreen( | ||||
|           fields: DistrictFields.getFields(context), | ||||
|           onSubmit: (data) => _handleSubmit(data), | ||||
|           title: 'District', | ||||
|           isLoading: viewModel.isLoading, | ||||
|           errorMessage: | ||||
|               viewModel.errorMessage.isNotEmpty ? viewModel.errorMessage : null, | ||||
|         ); | ||||
|       }, | ||||
|     ); | ||||
|   } | ||||
| 
 | ||||
|   Future<void> _handleSubmit(Map<String, dynamic> formData) async { | ||||
|     final provider = | ||||
|         Provider.of<DistrictViewModelScreen>(context, listen: false); | ||||
|     final success = await provider.createEntity(formData); | ||||
| 
 | ||||
|     if (success && mounted) { | ||||
|       Navigator.pop(context); | ||||
|     } | ||||
|   } | ||||
| } | ||||
| @ -0,0 +1,92 @@ | ||||
| // ignore_for_file: use_build_context_synchronously | ||||
| import 'package:flutter/material.dart'; | ||||
| import 'package:provider/provider.dart'; | ||||
| import '../../../../BuilderField/shared/ui/entity_details.dart'; | ||||
| import '../District_viewModel/District_view_model_screen.dart'; | ||||
| import 'District_update_entity_screen.dart'; | ||||
| 
 | ||||
| class DistrictDetailsScreen extends StatefulWidget { | ||||
|   final Map<String, dynamic> entity; | ||||
| 
 | ||||
|   const DistrictDetailsScreen({ | ||||
|     super.key, | ||||
|     required this.entity, | ||||
|   }); | ||||
| 
 | ||||
|   @override | ||||
|   State<DistrictDetailsScreen> createState() => _DistrictDetailsScreenState(); | ||||
| } | ||||
| 
 | ||||
| class _DistrictDetailsScreenState extends State<DistrictDetailsScreen> { | ||||
|   void _navigateToUpdateScreen(Map<String, dynamic> entity) { | ||||
|     Navigator.push( | ||||
|       context, | ||||
|       MaterialPageRoute( | ||||
|         builder: (context) => ChangeNotifierProvider( | ||||
|           create: (context) => DistrictViewModelScreen(), | ||||
|           child: DistrictUpdateEntityScreen(entity: entity), | ||||
|         ), | ||||
|       ), | ||||
|     ).then((_) { | ||||
|       // Refresh the details screen with updated data | ||||
|       setState(() {}); | ||||
|     }); | ||||
|   } | ||||
| 
 | ||||
|   void _showDeleteDialog(Map<String, dynamic> entity) { | ||||
|     showDialog( | ||||
|       context: context, | ||||
|       builder: (BuildContext context) { | ||||
|         return AlertDialog( | ||||
|           title: const Text('Confirm Deletion'), | ||||
|           content: const Text('Are you sure you want to delete this District?'), | ||||
|           actions: [ | ||||
|             TextButton( | ||||
|               child: const Text('Cancel'), | ||||
|               onPressed: () { | ||||
|                 Navigator.of(context).pop(); | ||||
|               }, | ||||
|             ), | ||||
|             TextButton( | ||||
|               child: const Text('Delete'), | ||||
|               onPressed: () async { | ||||
|                 Navigator.of(context).pop(); | ||||
|                 final vm = | ||||
|                     Provider.of<DistrictViewModelScreen>(context, listen: false); | ||||
|                 final success = await vm.deleteEntity(entity['id']); | ||||
|                 if (success && mounted) { | ||||
|                   Navigator.pop(context); // Go back to list | ||||
|                 } | ||||
|               }, | ||||
|             ), | ||||
|           ], | ||||
|         ); | ||||
|       }, | ||||
|     ); | ||||
|   } | ||||
| 
 | ||||
|   @override | ||||
|   Widget build(BuildContext context) { | ||||
|     return Consumer<DistrictViewModelScreen>( | ||||
|       builder: (context, viewModel, child) { | ||||
|         return EntityDetails( | ||||
|           entity: widget.entity, | ||||
|           onEdit: (entity) => _navigateToUpdateScreen(entity), | ||||
|           onDelete: (entity) => _showDeleteDialog(entity), | ||||
|           title: 'District', | ||||
|           displayFields: [ | ||||
|   {'key': 'district_name', 'label': 'district name', 'type': 'text'}, | ||||
| 
 | ||||
|   {'key': 'description', 'label': 'Description', 'type': 'textarea'}, | ||||
| 
 | ||||
|   {'key': 'active', 'label': 'Active', 'type': 'toggle_switch'}, | ||||
| 
 | ||||
|   {'key': 'state_name', 'label': 'state name', 'type': 'text'}, | ||||
| 
 | ||||
|           ], | ||||
|           isLoading: viewModel.isLoading, | ||||
|         ); | ||||
|       }, | ||||
|     ); | ||||
|   } | ||||
| } | ||||
| @ -0,0 +1,152 @@ | ||||
| // ignore_for_file: use_build_context_synchronously | ||||
| import 'package:flutter/material.dart'; | ||||
| import 'package:intl/intl.dart'; | ||||
| import 'package:base_project/BuilderField/shared/ui/entity_list.dart'; | ||||
| import 'District_create_entity_screen.dart'; | ||||
| import 'District_update_entity_screen.dart'; | ||||
| import '../District_viewModel/District_view_model_screen.dart'; | ||||
| import 'District_details_screen.dart';import 'package:flutter/services.dart'; | ||||
| import 'package:speech_to_text/speech_to_text.dart' as stt; | ||||
| import '../../../../theme/app_style.dart'; | ||||
| import '../../../../utils/size_utils.dart'; | ||||
| import '../../../../widgets/custom_icon_button.dart'; | ||||
| import '../../../../utils/image_constant.dart'; | ||||
| import '../../../../widgets/app_bar/appbar_image.dart'; | ||||
| import '../../../../widgets/app_bar/appbar_title.dart'; | ||||
| import '../../../../widgets/app_bar/custom_app_bar.dart'; | ||||
| import '../../../../theme/app_decoration.dart'; | ||||
| import 'package:multi_select_flutter/multi_select_flutter.dart'; | ||||
| import '../../../../Reuseable/reusable_text_field.dart'; | ||||
| import 'package:provider/provider.dart'; | ||||
| import '../../../../utils/toast_messages/toast_message_util.dart'; | ||||
| import 'package:fluttertoast/fluttertoast.dart'; | ||||
| 
 | ||||
| class District_entity_list_screen extends StatefulWidget { | ||||
|   static const String routeName = '/entity-list'; | ||||
| 
 | ||||
|   @override | ||||
|   _District_entity_list_screenState createState() => _District_entity_list_screenState(); | ||||
| } | ||||
| 
 | ||||
| class _District_entity_list_screenState extends State<District_entity_list_screen> { | ||||
|   @override | ||||
|   void initState() { | ||||
|     super.initState(); | ||||
|     _loadData(); | ||||
|   } | ||||
| 
 | ||||
|   void _loadData() { | ||||
|     WidgetsBinding.instance.addPostFrameCallback((_) { | ||||
|       if (mounted) { | ||||
|         final vm = Provider.of<DistrictViewModelScreen>(context, listen: false); | ||||
|         vm.getAllWithPagination(refresh: true); | ||||
|       } | ||||
|     }); | ||||
|   } | ||||
| 
 | ||||
|   void _navigateToCreateScreen() { | ||||
|     Navigator.push( | ||||
|       context, | ||||
|       MaterialPageRoute( | ||||
|         builder: (context) => ChangeNotifierProvider( | ||||
|           create: (context) => DistrictViewModelScreen(), | ||||
|           child: const DistrictCreateEntityScreen(), | ||||
|         ), | ||||
|       ), | ||||
|     ).then((_) { | ||||
|       final vm = Provider.of<DistrictViewModelScreen>(context, listen: false); | ||||
|       vm.refreshData(); | ||||
|     }); | ||||
|   } | ||||
| 
 | ||||
|   void _navigateToUpdateScreen(Map<String, dynamic> entity) { | ||||
|     Navigator.push( | ||||
|       context, | ||||
|       MaterialPageRoute( | ||||
|         builder: (context) => ChangeNotifierProvider( | ||||
|           create: (context) => DistrictViewModelScreen(), | ||||
|           child: DistrictUpdateEntityScreen(entity: entity), | ||||
|         ), | ||||
|       ), | ||||
|     ).then((_) { | ||||
|       final vm = Provider.of<DistrictViewModelScreen>(context, listen: false); | ||||
|       vm.refreshData(); | ||||
|     }); | ||||
|   } | ||||
| 
 | ||||
|   void _navigateToDetailsScreen(Map<String, dynamic> entity) { | ||||
|     Navigator.push( | ||||
|       context, | ||||
|       MaterialPageRoute( | ||||
|         builder: (context) => ChangeNotifierProvider( | ||||
|           create: (context) => DistrictViewModelScreen(), | ||||
|           child: DistrictDetailsScreen(entity: entity), | ||||
|         ), | ||||
|       ), | ||||
|     ); | ||||
|   } | ||||
| 
 | ||||
|   void _showDeleteDialog(Map<String, dynamic> entity) { | ||||
|  final parentContext = context;  | ||||
|     showDialog( | ||||
|       context: context, | ||||
|       builder: (BuildContext context) { | ||||
|         return AlertDialog( | ||||
|           title: const Text('Confirm Deletion'), | ||||
|           content: const Text('Are you sure you want to delete this District?'), | ||||
|           actions: [ | ||||
|             TextButton( | ||||
|               child: const Text('Cancel'), | ||||
|               onPressed: () { | ||||
|                 Navigator.of(context).pop(); | ||||
|               }, | ||||
|             ), | ||||
|             TextButton( | ||||
|               child: const Text('Delete'), | ||||
|               onPressed: () async { | ||||
|                 Navigator.of(context).pop(); | ||||
|                 final vm = | ||||
|                     Provider.of<DistrictViewModelScreen>(parentContext, listen: false); | ||||
|                 await vm.deleteEntity(entity['id']); | ||||
|               }, | ||||
|             ), | ||||
|           ], | ||||
|         ); | ||||
|       }, | ||||
|     ); | ||||
|   } | ||||
| 
 | ||||
|   @override | ||||
|   Widget build(BuildContext context) { | ||||
|     return Consumer<DistrictViewModelScreen>( | ||||
|       builder: (context, viewModel, child) { | ||||
|         return EntityList( | ||||
|           entities: viewModel.filteredList, | ||||
|           isLoading: viewModel.isLoading, | ||||
|           errorMessage: | ||||
|               viewModel.errorMessage.isNotEmpty ? viewModel.errorMessage : null, | ||||
|           hasMoreData: viewModel.hasMoreData, | ||||
|           searchQuery: viewModel.searchQuery, | ||||
|           onSearchChanged: (query) => viewModel.searchdistrict(query), | ||||
|           onEdit: (entity) => _navigateToUpdateScreen(entity), | ||||
|           onDelete: (entity) => _showDeleteDialog(entity), | ||||
|           onTap: (entity) => _navigateToDetailsScreen(entity), | ||||
|           onRefresh: () => viewModel.refreshData(), | ||||
|           onLoadMore: () => viewModel.getAllWithPagination(), | ||||
|           title: 'District', | ||||
|           onAddNew: _navigateToCreateScreen, | ||||
|           displayFields: [ | ||||
|   {'key': 'district_name', 'label': 'district name', 'type': 'text'}, | ||||
| 
 | ||||
|   {'key': 'description', 'label': 'Description', 'type': 'textarea'}, | ||||
| 
 | ||||
|   {'key': 'active', 'label': 'Active', 'type': 'toggle_switch'}, | ||||
| 
 | ||||
|   {'key': 'state_name', 'label': 'state name', 'type': 'text'}, | ||||
| 
 | ||||
|           ], | ||||
|         ); | ||||
|       }, | ||||
|     ); | ||||
|   } | ||||
| } | ||||
| @ -0,0 +1,84 @@ | ||||
| import 'package:base_project/BuilderField/shared/fields/number_field.dart'; | ||||
| import 'package:base_project/BuilderField/shared/fields/password_field.dart'; | ||||
| import 'package:base_project/BuilderField/shared/fields/phone_field.dart'; | ||||
| import 'package:base_project/BuilderField/shared/fields/custom_text_field.dart'; | ||||
| 
 | ||||
| import '../../../../BuilderField/shared/fields/base_field.dart'; | ||||
| 
 | ||||
| import '../../../../BuilderField/shared/fields/date_field.dart'; | ||||
| import '../../../../BuilderField/shared/fields/datetime_field.dart'; | ||||
| import '../../../../BuilderField/shared/fields/email_field.dart'; | ||||
| import 'package:base_project/BuilderField/shared/fields/url_field.dart'; | ||||
| import 'package:flutter/material.dart'; | ||||
| import 'package:provider/provider.dart'; | ||||
| 
 | ||||
| import '../../../../BuilderField/shared/fields/custom_text_field.dart' as shared_text; | ||||
| import '../../../../BuilderField/shared/fields/one_to_one_relation_field.dart'; | ||||
| import '../../../../BuilderField/shared/fields/calculated_field.dart'; | ||||
| import '../../../../BuilderField/shared/fields/one_to_many_field.dart'; | ||||
| import '../../../../BuilderField/shared/fields/value_list_picker_field.dart'; | ||||
| import '../../../../BuilderField/shared/fields/captcha_field.dart'; | ||||
| import '../../../../BuilderField/shared/fields/switch_field.dart'; | ||||
| import '../../../../BuilderField/shared/fields/url_field.dart'; | ||||
| 
 | ||||
| import '../../../../BuilderField/shared/fields/audio_upload_field.dart'; | ||||
| import '../../../../BuilderField/shared/fields/checkbox_field.dart'; | ||||
| import '../../../../BuilderField/shared/fields/file_upload_field.dart'; | ||||
| import '../../../../BuilderField/shared/fields/image_upload_field.dart'; | ||||
| import '../../../../BuilderField/shared/fields/radio_field.dart'; | ||||
| import '../../../../BuilderField/shared/fields/video_upload_field.dart'; | ||||
| 
 | ||||
| import '../../../../BuilderField/shared/fields/autocomplete_dropdown_field.dart'; | ||||
| import '../../../../BuilderField/shared/fields/autocomplete_multiselect_field.dart'; | ||||
| import '../../../../BuilderField/shared/fields/one_to_one_relation_field.dart'; | ||||
| import '../../../../BuilderField/shared/fields/data_grid_field.dart'; | ||||
| import '../../../../BuilderField/shared/fields/dropdown_field.dart'; | ||||
| import '../../../../BuilderField/shared/fields/dynamic_dropdown_field.dart'; | ||||
| import '../../../../BuilderField/shared/fields/dynamic_multiselect_dropdown_field.dart'; | ||||
| import '../../../../BuilderField/shared/fields/static_multiselect_field.dart'; | ||||
| import '../../../../BuilderField/shared/fields/currency_field.dart'; | ||||
| import '../../../../BuilderField/shared/fields/field_group_field.dart'; | ||||
| import '../../../../BuilderField/shared/fields/qr_code_field.dart'; | ||||
| import '../../../../BuilderField/shared/fields/barcode_field.dart'; | ||||
| import '../../../../BuilderField/shared/fields/dependent_dropdown_field.dart'; | ||||
|  import '../District_viewModel/District_view_model_screen.dart';/// Field definitions for District entity | ||||
| /// This defines the structure and validation for District forms | ||||
| class DistrictFields { | ||||
|   /// Get field definitions for District entity | ||||
|   static List<BaseField> getFields(BuildContext context) { | ||||
|     final viewModel = | ||||
|         Provider.of<DistrictViewModelScreen>(context, listen: false); | ||||
|     return [ | ||||
|       // Basic Information | ||||
|  CustomTextField( | ||||
|         fieldKey: 'district_name', | ||||
|         label: 'district name', | ||||
|         hint: 'Enter district name', | ||||
|         isRequired: true, | ||||
|         maxLength: 50, | ||||
|       ), | ||||
| 
 | ||||
| CustomTextField( | ||||
|         fieldKey: 'description', | ||||
|         label: 'Description', | ||||
|         hint: 'Enter Description', | ||||
|         isRequired: false, | ||||
|         maxLength: 1000, | ||||
|       ), | ||||
| 
 | ||||
|  SwitchField( | ||||
|         fieldKey: 'active', | ||||
|         label: 'Active', | ||||
|       ), | ||||
| 
 | ||||
|  CustomTextField( | ||||
|         fieldKey: 'state_name', | ||||
|         label: 'state name', | ||||
|         hint: 'Enter state name', | ||||
|         isRequired: true, | ||||
|         maxLength: 50, | ||||
|       ), | ||||
| 
 | ||||
|     ]; | ||||
|   } | ||||
| } | ||||
| @ -0,0 +1,79 @@ | ||||
| // ignore_for_file: use_build_context_synchronously | ||||
| import 'dart:convert'; | ||||
| import 'package:provider/provider.dart'; | ||||
| import '../District_viewModel/District_view_model_screen.dart'; | ||||
| import 'package:base_project/BuilderField/shared/ui/entity_screens.dart'; | ||||
| import 'District_fields.dart';import '../../../../utils/image_constant.dart'; | ||||
| import '../../../../utils/size_utils.dart'; | ||||
| import '../../../../theme/app_style.dart'; | ||||
| import '../../../../widgets/app_bar/appbar_image.dart'; | ||||
| import '../../../../widgets/app_bar/appbar_title.dart'; | ||||
| import '../../../../widgets/app_bar/custom_app_bar.dart'; | ||||
| import 'package:barcode_widget/barcode_widget.dart'; | ||||
| import 'package:fluttertoast/fluttertoast.dart'; | ||||
| import '../../../../widgets/custom_button.dart'; | ||||
| import '../../../../widgets/custom_text_form_field.dart'; | ||||
| import 'package:flutter/material.dart'; | ||||
| import 'package:autocomplete_textfield/autocomplete_textfield.dart'; | ||||
| import 'package:qr_flutter/qr_flutter.dart'; | ||||
| import 'package:intl/intl.dart'; | ||||
| 
 | ||||
| import 'dart:math'; | ||||
| import '../../../../Reuseable/reusable_text_field.dart'; | ||||
| import '../../../../Reuseable/reusable_date_picker_field.dart'; | ||||
| import '../../../../Reuseable/reusable_date_time_picker_field.dart'; | ||||
| import '../../../../Reuseable/reusable_dropdown_field.dart'; | ||||
| import 'package:flutter/services.dart'; | ||||
| class DistrictUpdateEntityScreen extends StatefulWidget { | ||||
|     final Map<String, dynamic> entity; | ||||
| 
 | ||||
| 
 | ||||
|   DistrictUpdateEntityScreen({required this.entity}); | ||||
| 
 | ||||
|   @override | ||||
|   _DistrictUpdateEntityScreenState createState() => _DistrictUpdateEntityScreenState(); | ||||
| } | ||||
| 
 | ||||
| class _DistrictUpdateEntityScreenState extends State<DistrictUpdateEntityScreen> { | ||||
|   final _formKey = GlobalKey<FormState>(); | ||||
| 
 | ||||
| @override | ||||
|   Widget build(BuildContext context) { | ||||
|     return Consumer<DistrictViewModelScreen>( | ||||
|       builder: (context, viewModel, child) { | ||||
| // Start with all fields, then remove upload fields (generic filter by keys) | ||||
|         final Set<String> hiddenKeys = {  | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|  }; | ||||
|         final fields = DistrictFields.getFields(context) | ||||
|             .where((f) => !hiddenKeys.contains(f.fieldKey)) | ||||
|             .toList();        return EntityUpdateScreen( | ||||
|           fields: fields, | ||||
|           initialData: widget.entity, | ||||
|           onSubmit: (data) => _handleSubmit(data), | ||||
|           title: 'District', | ||||
|           isLoading: viewModel.isLoading, | ||||
|           errorMessage: | ||||
|               viewModel.errorMessage.isNotEmpty ? viewModel.errorMessage : null, | ||||
|         ); | ||||
|       }, | ||||
|     ); | ||||
|   } | ||||
| 
 | ||||
|   Future<void> _handleSubmit(Map<String, dynamic> formData) async { | ||||
|     final provider = | ||||
|         Provider.of<DistrictViewModelScreen>(context, listen: false); | ||||
|     final success = await provider.updateEntity(widget.entity['id'], formData); | ||||
| 
 | ||||
|     if (success && mounted) { | ||||
|       Navigator.pop(context); | ||||
|     } | ||||
|   } | ||||
| } | ||||
| @ -0,0 +1,97 @@ | ||||
| import 'package:dio/dio.dart'; | ||||
| import '../../../../data/network/base_network_service.dart'; | ||||
| import '../../../../data/network/network_api_service.dart'; | ||||
| import '../../../../resources/api_constants.dart'; | ||||
| import 'package:base_project/data/response/api_response.dart'; | ||||
| 
 | ||||
| class DistrictRepoScreen { | ||||
| 
 | ||||
|   final String baseUrl = ApiConstants.baseUrl; | ||||
|   final BaseNetworkService _helper = NetworkApiService(); | ||||
|   final String _endpointPath = '/District/District'; | ||||
| 
 | ||||
|   Future<ApiResponse<List<Map<String, dynamic>>>> getEntities() async { | ||||
|     try { | ||||
|       final response = | ||||
|           await _helper.getGetApiResponse('$baseUrl$_endpointPath'); | ||||
|       print('Response received: $response'); | ||||
|       List<Map<String, dynamic>> entities = const []; | ||||
|       if (response is List) { | ||||
|         entities = response | ||||
|             .whereType<Map>() | ||||
|             .map((e) => Map<String, dynamic>.from(e as Map)) | ||||
|             .toList(); | ||||
|       } else if (response is Map<String, dynamic>) { | ||||
|         final dynamic content = response['content']; | ||||
|         if (content is List) { | ||||
|           entities = content | ||||
|               .whereType<Map>() | ||||
|               .map((e) => Map<String, dynamic>.from(e as Map)) | ||||
|               .toList(); | ||||
|         } | ||||
|       } | ||||
|       return ApiResponse.success(entities); | ||||
|     } catch (e) { | ||||
|       print(' error got $e'); | ||||
|       return ApiResponse.error('Failed to get all entities: $e'); | ||||
|     } | ||||
|   }  | ||||
| 
 | ||||
|   Future<ApiResponse<List<Map<String, dynamic>>>> getAllWithPagination( | ||||
|       int page, int size) async { | ||||
|     try { | ||||
|       final response = await _helper.getGetApiResponse( | ||||
|           '$baseUrl$_endpointPath/getall/page?page=$page&size=$size'); | ||||
| 
 | ||||
|       if (response is Map<String, dynamic> && response['content'] is List) { | ||||
|         final List<Map<String, dynamic>> entities = | ||||
|             (response['content'] as List).cast<Map<String, dynamic>>().toList(); | ||||
|         return ApiResponse.success(entities); | ||||
|       } else { | ||||
|         return ApiResponse.error('Invalid response format'); | ||||
|       } | ||||
|     } catch (e) { | ||||
|       return ApiResponse.error('Failed to get all without pagination: $e'); | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
|   Future<ApiResponse<Map<String, dynamic>>> createEntity( | ||||
|       Map<String, dynamic> entity) async { | ||||
|     try { | ||||
|       print("in post api$entity"); | ||||
|       final response = | ||||
|           await _helper.getPostApiResponse('$baseUrl$_endpointPath', entity); | ||||
|       return ApiResponse.success(response as Map<String, dynamic>); | ||||
|     } catch (e) { | ||||
|       return ApiResponse.error('Failed to create entity: $e'); | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
|   Future<ApiResponse<Map<String, dynamic>>> updateEntity( | ||||
|       int entityId, Map<String, dynamic> entity) async { | ||||
|     try { | ||||
|       final response = await _helper.getPutApiResponse( | ||||
|           '$baseUrl$_endpointPath/$entityId', entity); | ||||
|       return ApiResponse.success(response as Map<String, dynamic>); | ||||
|     } catch (e) { | ||||
|       return ApiResponse.error('Failed to update entity: $e'); | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
|   Future<ApiResponse<void>> deleteEntity(int entityId) async { | ||||
|     try { | ||||
|       await _helper.getDeleteApiResponse('$baseUrl$_endpointPath/$entityId'); | ||||
|       return ApiResponse.success(null); | ||||
|     } catch (e) { | ||||
|       return ApiResponse.error('Failed to delete entity: $e'); | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| } | ||||
| @ -0,0 +1,321 @@ | ||||
| import 'package:base_project/data/response/status.dart'; | ||||
| import 'dart:typed_data'; | ||||
| import 'package:dio/dio.dart'; | ||||
| import 'package:http_parser/http_parser.dart'; | ||||
| import '../../../../utils/toast_messages/toast_message_util.dart'; | ||||
| import '../../../../BuilderField/shared/utils/entity_field_store.dart'; | ||||
| import 'package:flutter/material.dart'; | ||||
| import '../District_Repo/District_repo_screen.dart'; | ||||
| 
 | ||||
| class DistrictViewModelScreen extends ChangeNotifier{ | ||||
|   final DistrictRepoScreen repo = DistrictRepoScreen(); | ||||
| 
 | ||||
|   | ||||
|   // State variables | ||||
|   List<Map<String, dynamic>> _districtList = []; | ||||
|   List<Map<String, dynamic>> _filteredList = []; | ||||
|   bool _isLoading = false; | ||||
|   String _errorMessage = ''; | ||||
|   int _currentPage = 0; | ||||
|   int _pageSize = 10; | ||||
|   bool _hasMoreData = true; | ||||
|   String _searchQuery = ''; | ||||
| 
 | ||||
|   // Getters | ||||
|   List<Map<String, dynamic>> get districtList => _districtList; | ||||
|   List<Map<String, dynamic>> get filteredList => _filteredList; | ||||
|   bool get isLoading => _isLoading; | ||||
|   String get errorMessage => _errorMessage; | ||||
|   bool get hasMoreData => _hasMoreData; | ||||
|   String get searchQuery => _searchQuery; | ||||
| 
 | ||||
|   // Set loading state | ||||
|   void _setLoading(bool loading) { | ||||
|     _isLoading = loading; | ||||
|     notifyListeners(); | ||||
|   } | ||||
| 
 | ||||
|   // Set error message | ||||
|   void _setError(String error) { | ||||
|     _errorMessage = error; | ||||
|     notifyListeners(); | ||||
|   } | ||||
| 
 | ||||
|   // Clear error | ||||
|   void clearError() { | ||||
|     _errorMessage = ''; | ||||
|     notifyListeners(); | ||||
|   } | ||||
| 
 | ||||
|   // Get district list | ||||
|   Future<void> getEntities() async { | ||||
|     _setLoading(true); | ||||
|     _setError(''); | ||||
| 
 | ||||
|     try { | ||||
|       final response = await repo.getEntities(); | ||||
| 
 | ||||
|       if (response.status == Status.SUCCESS) { | ||||
|         _districtList = response.data ?? []; | ||||
|         _filteredList = List.from(_districtList); | ||||
|         _currentPage = 0; | ||||
|         _hasMoreData = true; | ||||
|       } else { | ||||
|         _setError(response.message ?? 'Failed to fetch district list'); | ||||
|       } | ||||
|     } catch (e) { | ||||
|       _setError('Failed to fetch district list: $e'); | ||||
|     } finally { | ||||
|       _setLoading(false); | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
|   // Get district list with pagination | ||||
|   Future<void> getAllWithPagination({bool refresh = false}) async { | ||||
|     if (refresh) { | ||||
|       _currentPage = 0; | ||||
|       _districtList.clear(); | ||||
|       _filteredList.clear(); | ||||
|       _hasMoreData = true; | ||||
|     } | ||||
| 
 | ||||
|     if (!_hasMoreData || _isLoading) return; | ||||
| 
 | ||||
|     _setLoading(true); | ||||
|     _setError(''); | ||||
| 
 | ||||
|     try { | ||||
|       final response = await repo.getAllWithPagination(_currentPage, _pageSize); | ||||
| 
 | ||||
|       if (response.status == Status.SUCCESS) { | ||||
|         final newItems = response.data ?? []; | ||||
| 
 | ||||
|         if (refresh) { | ||||
|           _districtList = newItems; | ||||
|         } else { | ||||
|           _districtList.addAll(newItems); | ||||
|         } | ||||
| 
 | ||||
|         _filteredList = List.from(_districtList); | ||||
|         _currentPage++; | ||||
| 
 | ||||
|         // Check if we have more data | ||||
|         _hasMoreData = newItems.length == _pageSize; | ||||
|       } else { | ||||
|         _setError(response.message ?? 'Failed to fetch District list'); | ||||
|       } | ||||
|     } catch (e) { | ||||
|       _setError('Failed to fetch district list: $e'); | ||||
|     } finally { | ||||
|       _setLoading(false); | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|   // Create District | ||||
|   Future<bool> createEntity(Map<String, dynamic> entity) async { | ||||
|     _setLoading(true); | ||||
|     _setError(''); | ||||
| 
 | ||||
|     try { | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|       final response = await repo.createEntity(entity); | ||||
| 
 | ||||
|       if (response.status == Status.SUCCESS) { | ||||
| // Get the response ID for image upload | ||||
| 
 | ||||
|         final responseId = response.data!['id'].toString(); | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|         ToastMessageUtil.showToast( | ||||
|           message: 'district created successfully', | ||||
|           toastType: ToastType.success, | ||||
|         ); | ||||
| 
 | ||||
|         // Refresh the list | ||||
|         await getEntities(); | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|         return true; | ||||
|       } else { | ||||
|         _setError(response.message ?? 'Failed to create District'); | ||||
|         ToastMessageUtil.showToast( | ||||
|           message: response.message ?? 'Failed to create District', | ||||
|           toastType: ToastType.error, | ||||
|         ); | ||||
|         return false; | ||||
|       } | ||||
|     } catch (e) { | ||||
|       _setError('Failed to create district: $e'); | ||||
|       ToastMessageUtil.showToast( | ||||
|         message: 'Failed to create District: $e', | ||||
|         toastType: ToastType.error, | ||||
|       ); | ||||
|       return false; | ||||
|     } finally { | ||||
|       _setLoading(false); | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
|   // Update district | ||||
|   Future<bool> updateEntity(int id, Map<String, dynamic> entity) async { | ||||
|     _setLoading(true); | ||||
|     _setError(''); | ||||
| 
 | ||||
|     try { | ||||
|       final response = await repo.updateEntity(id, entity); | ||||
| 
 | ||||
|       if (response.status == Status.SUCCESS) { | ||||
|         ToastMessageUtil.showToast( | ||||
|           message: 'District updated successfully', | ||||
|           toastType: ToastType.success, | ||||
|         ); | ||||
| 
 | ||||
|         // Update the item in the list | ||||
|         final index = _districtList.indexWhere((item) => item['id'] == id); | ||||
|         if (index != -1) { | ||||
|           _districtList[index] = response.data!; | ||||
|           _filteredList = List.from(_districtList); | ||||
|           notifyListeners(); | ||||
|         } | ||||
|         return true; | ||||
|       } else { | ||||
|         _setError(response.message ?? 'Failed to update District'); | ||||
|         ToastMessageUtil.showToast( | ||||
|           message: response.message ?? 'Failed to update District', | ||||
|           toastType: ToastType.error, | ||||
|         ); | ||||
|         return false; | ||||
|       } | ||||
|     } catch (e) { | ||||
|       _setError('Failed to update district: $e'); | ||||
|       ToastMessageUtil.showToast( | ||||
|         message: 'Failed to update District: $e', | ||||
|         toastType: ToastType.error, | ||||
|       ); | ||||
|       return false; | ||||
|     } finally { | ||||
|       _setLoading(false); | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
|   // Delete district | ||||
|   Future<bool> deleteEntity(int id) async { | ||||
|     _setLoading(true); | ||||
|     _setError(''); | ||||
| 
 | ||||
|     try { | ||||
|       final response = await repo.deleteEntity(id); | ||||
| 
 | ||||
|       if (response.status == Status.SUCCESS) { | ||||
|         ToastMessageUtil.showToast( | ||||
|           message: 'District deleted successfully', | ||||
|           toastType: ToastType.success, | ||||
|         ); | ||||
| 
 | ||||
|         // Remove the item from the list | ||||
|         _districtList.removeWhere((item) => item['id'] == id); | ||||
|         _filteredList = List.from(_districtList); | ||||
|         notifyListeners(); | ||||
|         return true; | ||||
|       } else { | ||||
|         _setError(response.message ?? 'Failed to delete District'); | ||||
|         ToastMessageUtil.showToast( | ||||
|           message: response.message ?? 'Failed to delete District', | ||||
|           toastType: ToastType.error, | ||||
|         ); | ||||
|         return false; | ||||
|       } | ||||
|     } catch (e) { | ||||
|       _setError('Failed to delete district: $e'); | ||||
|       ToastMessageUtil.showToast( | ||||
|         message: 'Failed to delete District: $e', | ||||
|         toastType: ToastType.error, | ||||
|       ); | ||||
|       return false; | ||||
|     } finally { | ||||
|       _setLoading(false); | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
|   // Search district | ||||
|   void searchdistrict(String query) { | ||||
|     _searchQuery = query; | ||||
| 
 | ||||
|     if (query.isEmpty) { | ||||
|       _filteredList = List.from(_districtList); | ||||
|     } else { | ||||
|       _filteredList = _districtList.where((item) { | ||||
|         return | ||||
| 
 | ||||
|               | ||||
| (item['district_name']?.toString().toLowerCase().contains(query.toLowerCase()) ??false) || | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|               | ||||
| (item['description']?.toString().toLowerCase().contains(query.toLowerCase()) ??false) || | ||||
| 
 | ||||
| 
 | ||||
| (item['active']?.toString().toLowerCase().contains(query.toLowerCase()) ??false) || | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|               | ||||
| (item['state_name']?.toString().toLowerCase().contains(query.toLowerCase()) ??false)  | ||||
| 
 | ||||
| 
 | ||||
| ; | ||||
|       }).toList(); | ||||
|     } | ||||
|     notifyListeners(); | ||||
|   } | ||||
| 
 | ||||
|   // Clear search | ||||
|   void clearSearch() { | ||||
|     _searchQuery = ''; | ||||
|     _filteredList = List.from(_districtList); | ||||
|     notifyListeners(); | ||||
|   } | ||||
| 
 | ||||
|   // Refresh data | ||||
|   Future<void> refreshData() async { | ||||
|     await getAllWithPagination(refresh: true); | ||||
|   } | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| } | ||||
| @ -0,0 +1,88 @@ | ||||
| import 'dart:typed_data'; | ||||
| import 'package:dio/dio.dart'; | ||||
| import 'package:http_parser/http_parser.dart'; | ||||
| import '../../../../resources/api_constants.dart'; | ||||
| import '../../../../data/network/base_network_service.dart'; | ||||
| import '../../../../data/network/network_api_service.dart'; | ||||
| 
 | ||||
| class StateApiService { | ||||
|   final String baseUrl = ApiConstants.baseUrl; | ||||
| 
 | ||||
|       final BaseNetworkService _helper = NetworkApiService(); | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|    Future<List<Map<String, dynamic>>> getEntities() async { | ||||
| 
 | ||||
|     try { | ||||
|       final response = await _helper.getGetApiResponse('$baseUrl/State/State'); | ||||
|       final entities = (response as List).cast<Map<String, dynamic>>(); | ||||
|       return entities; | ||||
|     } catch (e) { | ||||
|       throw Exception('Failed to get all entities: $e'); | ||||
|     } | ||||
|   } | ||||
| Future<List<Map<String, dynamic>>> getAllWithPagination( | ||||
|        int page, int size) async { | ||||
|     try { | ||||
|             final response = | ||||
|           await _helper.getGetApiResponse('$baseUrl/State/State/getall/page?page=$page&size=$size'); | ||||
|       final entities = | ||||
|           (response['content'] as List).cast<Map<String, dynamic>>(); | ||||
|       return entities; | ||||
|     } catch (e) { | ||||
|       throw Exception('Failed to get all without pagination: $e'); | ||||
|     } | ||||
|   } | ||||
|   Future<Map<String, dynamic>> createEntity( | ||||
|        Map<String, dynamic> entity) async { | ||||
|     try { | ||||
|             print("in post api$entity"); | ||||
|       final response = | ||||
|           await _helper.getPostApiResponse('$baseUrl/State/State', entity); | ||||
| 
 | ||||
|       print(entity); | ||||
| 
 | ||||
|       // Assuming the response is a Map<String, dynamic> | ||||
|       Map<String, dynamic> responseData = response; | ||||
| 
 | ||||
|       return responseData; | ||||
|     } catch (e) { | ||||
|       throw Exception('Failed to create entity: $e'); | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|   Future<void> updateEntity( int entityId, Map<String, dynamic> entity) async { | ||||
|     try { | ||||
|      await _helper.getPutApiResponse('$baseUrl/State/State/$entityId', | ||||
|       entity);                print(entity); | ||||
| 
 | ||||
|     } catch (e) { | ||||
|       throw Exception('Failed to update entity: $e'); | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
|   Future<void> deleteEntity( int entityId) async { | ||||
|     try { | ||||
|  await _helper.getDeleteApiResponse('$baseUrl/State/State/$entityId'); | ||||
|     } catch (e) { | ||||
|       throw Exception('Failed to delete entity: $e'); | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| } | ||||
| @ -0,0 +1,84 @@ | ||||
| // ignore_for_file: use_build_context_synchronously | ||||
| import 'dart:convert'; | ||||
| import 'package:flutter/material.dart'; | ||||
| import 'package:file_picker/file_picker.dart'; | ||||
| import 'package:image_picker/image_picker.dart'; | ||||
| import 'package:provider/provider.dart'; | ||||
| import '../State_viewModel/State_view_model_screen.dart'; | ||||
| import 'State_fields.dart';import 'package:base_project/BuilderField/shared/ui/entity_screens.dart'; | ||||
| import '../../../../utils/image_constant.dart'; | ||||
| import '../../../../utils/size_utils.dart'; | ||||
| import '../../../../theme/app_style.dart'; | ||||
| import '../../../../widgets/app_bar/appbar_image.dart'; | ||||
| import '../../../../widgets/app_bar/appbar_title.dart'; | ||||
| import '../../../../widgets/app_bar/custom_app_bar.dart'; | ||||
| import '../../../../widgets/custom_button.dart'; | ||||
| import '../../../../widgets/custom_text_form_field.dart';  | ||||
| import '../../../../widgets/custom_dropdown_field.dart'; | ||||
| import 'dart:math'; | ||||
| import 'package:qr_flutter/qr_flutter.dart'; | ||||
| import 'package:barcode_widget/barcode_widget.dart'; | ||||
| import 'package:intl/intl.dart'; | ||||
|   | ||||
| import 'package:autocomplete_textfield/autocomplete_textfield.dart'; | ||||
| import 'package:http/http.dart' as http; | ||||
| import 'package:flutter/services.dart'; | ||||
| import 'package:image_picker/image_picker.dart'; | ||||
| import 'package:fluttertoast/fluttertoast.dart'; | ||||
| import '../../../../Reuseable/reusable_date_picker_field.dart'; | ||||
| import '../../../../Reuseable/reusable_date_time_picker_field.dart' | ||||
| ;import 'package:multi_select_flutter/multi_select_flutter.dart'; | ||||
| import 'package:just_audio/just_audio.dart'; | ||||
| import 'package:video_player/video_player.dart'; | ||||
| import 'package:google_fonts/google_fonts.dart'; | ||||
| import 'package:lottie/lottie.dart'; | ||||
| import '../../../../utils/toast_messages/toast_message_util.dart'; | ||||
| import 'dart:io'; | ||||
| import '../../../../Reuseable/reusable_text_field.dart'; | ||||
| import '../../../../Reuseable/reusable_dropdown_field.dart'; | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| class StateCreateEntityScreen extends StatefulWidget { | ||||
|   const StateCreateEntityScreen({super.key}); | ||||
| 
 | ||||
|   @override | ||||
|   _StateCreateEntityScreenState createState() => _StateCreateEntityScreenState(); | ||||
| } | ||||
| 
 | ||||
| class _StateCreateEntityScreenState extends State<StateCreateEntityScreen> { | ||||
| 
 | ||||
| final Map<String, dynamic> formData = {}; | ||||
|   final _formKey = GlobalKey<FormState>(); | ||||
|    | ||||
|   @override | ||||
|   Widget build(BuildContext context) { | ||||
|     return Consumer<StateViewModelScreen>( | ||||
|       builder: (context, viewModel, child) { | ||||
|         return EntityCreateScreen( | ||||
|           fields: StateFields.getFields(context), | ||||
|           onSubmit: (data) => _handleSubmit(data), | ||||
|           title: 'State', | ||||
|           isLoading: viewModel.isLoading, | ||||
|           errorMessage: | ||||
|               viewModel.errorMessage.isNotEmpty ? viewModel.errorMessage : null, | ||||
|         ); | ||||
|       }, | ||||
|     ); | ||||
|   } | ||||
| 
 | ||||
|   Future<void> _handleSubmit(Map<String, dynamic> formData) async { | ||||
|     final provider = | ||||
|         Provider.of<StateViewModelScreen>(context, listen: false); | ||||
|     final success = await provider.createEntity(formData); | ||||
| 
 | ||||
|     if (success && mounted) { | ||||
|       Navigator.pop(context); | ||||
|     } | ||||
|   } | ||||
| } | ||||
| @ -0,0 +1,92 @@ | ||||
| // ignore_for_file: use_build_context_synchronously | ||||
| import 'package:flutter/material.dart'; | ||||
| import 'package:provider/provider.dart'; | ||||
| import '../../../../BuilderField/shared/ui/entity_details.dart'; | ||||
| import '../State_viewModel/State_view_model_screen.dart'; | ||||
| import 'State_update_entity_screen.dart'; | ||||
| 
 | ||||
| class StateDetailsScreen extends StatefulWidget { | ||||
|   final Map<String, dynamic> entity; | ||||
| 
 | ||||
|   const StateDetailsScreen({ | ||||
|     super.key, | ||||
|     required this.entity, | ||||
|   }); | ||||
| 
 | ||||
|   @override | ||||
|   State<StateDetailsScreen> createState() => _StateDetailsScreenState(); | ||||
| } | ||||
| 
 | ||||
| class _StateDetailsScreenState extends State<StateDetailsScreen> { | ||||
|   void _navigateToUpdateScreen(Map<String, dynamic> entity) { | ||||
|     Navigator.push( | ||||
|       context, | ||||
|       MaterialPageRoute( | ||||
|         builder: (context) => ChangeNotifierProvider( | ||||
|           create: (context) => StateViewModelScreen(), | ||||
|           child: StateUpdateEntityScreen(entity: entity), | ||||
|         ), | ||||
|       ), | ||||
|     ).then((_) { | ||||
|       // Refresh the details screen with updated data | ||||
|       setState(() {}); | ||||
|     }); | ||||
|   } | ||||
| 
 | ||||
|   void _showDeleteDialog(Map<String, dynamic> entity) { | ||||
|     showDialog( | ||||
|       context: context, | ||||
|       builder: (BuildContext context) { | ||||
|         return AlertDialog( | ||||
|           title: const Text('Confirm Deletion'), | ||||
|           content: const Text('Are you sure you want to delete this State?'), | ||||
|           actions: [ | ||||
|             TextButton( | ||||
|               child: const Text('Cancel'), | ||||
|               onPressed: () { | ||||
|                 Navigator.of(context).pop(); | ||||
|               }, | ||||
|             ), | ||||
|             TextButton( | ||||
|               child: const Text('Delete'), | ||||
|               onPressed: () async { | ||||
|                 Navigator.of(context).pop(); | ||||
|                 final vm = | ||||
|                     Provider.of<StateViewModelScreen>(context, listen: false); | ||||
|                 final success = await vm.deleteEntity(entity['id']); | ||||
|                 if (success && mounted) { | ||||
|                   Navigator.pop(context); // Go back to list | ||||
|                 } | ||||
|               }, | ||||
|             ), | ||||
|           ], | ||||
|         ); | ||||
|       }, | ||||
|     ); | ||||
|   } | ||||
| 
 | ||||
|   @override | ||||
|   Widget build(BuildContext context) { | ||||
|     return Consumer<StateViewModelScreen>( | ||||
|       builder: (context, viewModel, child) { | ||||
|         return EntityDetails( | ||||
|           entity: widget.entity, | ||||
|           onEdit: (entity) => _navigateToUpdateScreen(entity), | ||||
|           onDelete: (entity) => _showDeleteDialog(entity), | ||||
|           title: 'State', | ||||
|           displayFields: [ | ||||
|   {'key': 'state_name', 'label': 'state name', 'type': 'text'}, | ||||
| 
 | ||||
|   {'key': 'description', 'label': 'Description', 'type': 'textarea'}, | ||||
| 
 | ||||
|   {'key': 'active', 'label': 'Active', 'type': 'toggle_switch'}, | ||||
| 
 | ||||
|   {'key': 'country_name', 'label': 'country name', 'type': 'text'}, | ||||
| 
 | ||||
|           ], | ||||
|           isLoading: viewModel.isLoading, | ||||
|         ); | ||||
|       }, | ||||
|     ); | ||||
|   } | ||||
| } | ||||
| @ -0,0 +1,152 @@ | ||||
| // ignore_for_file: use_build_context_synchronously | ||||
| import 'package:flutter/material.dart'; | ||||
| import 'package:intl/intl.dart'; | ||||
| import 'package:base_project/BuilderField/shared/ui/entity_list.dart'; | ||||
| import 'State_create_entity_screen.dart'; | ||||
| import 'State_update_entity_screen.dart'; | ||||
| import '../State_viewModel/State_view_model_screen.dart'; | ||||
| import 'State_details_screen.dart';import 'package:flutter/services.dart'; | ||||
| import 'package:speech_to_text/speech_to_text.dart' as stt; | ||||
| import '../../../../theme/app_style.dart'; | ||||
| import '../../../../utils/size_utils.dart'; | ||||
| import '../../../../widgets/custom_icon_button.dart'; | ||||
| import '../../../../utils/image_constant.dart'; | ||||
| import '../../../../widgets/app_bar/appbar_image.dart'; | ||||
| import '../../../../widgets/app_bar/appbar_title.dart'; | ||||
| import '../../../../widgets/app_bar/custom_app_bar.dart'; | ||||
| import '../../../../theme/app_decoration.dart'; | ||||
| import 'package:multi_select_flutter/multi_select_flutter.dart'; | ||||
| import '../../../../Reuseable/reusable_text_field.dart'; | ||||
| import 'package:provider/provider.dart'; | ||||
| import '../../../../utils/toast_messages/toast_message_util.dart'; | ||||
| import 'package:fluttertoast/fluttertoast.dart'; | ||||
| 
 | ||||
| class State_entity_list_screen extends StatefulWidget { | ||||
|   static const String routeName = '/entity-list'; | ||||
| 
 | ||||
|   @override | ||||
|   _State_entity_list_screenState createState() => _State_entity_list_screenState(); | ||||
| } | ||||
| 
 | ||||
| class _State_entity_list_screenState extends State<State_entity_list_screen> { | ||||
|   @override | ||||
|   void initState() { | ||||
|     super.initState(); | ||||
|     _loadData(); | ||||
|   } | ||||
| 
 | ||||
|   void _loadData() { | ||||
|     WidgetsBinding.instance.addPostFrameCallback((_) { | ||||
|       if (mounted) { | ||||
|         final vm = Provider.of<StateViewModelScreen>(context, listen: false); | ||||
|         vm.getAllWithPagination(refresh: true); | ||||
|       } | ||||
|     }); | ||||
|   } | ||||
| 
 | ||||
|   void _navigateToCreateScreen() { | ||||
|     Navigator.push( | ||||
|       context, | ||||
|       MaterialPageRoute( | ||||
|         builder: (context) => ChangeNotifierProvider( | ||||
|           create: (context) => StateViewModelScreen(), | ||||
|           child: const StateCreateEntityScreen(), | ||||
|         ), | ||||
|       ), | ||||
|     ).then((_) { | ||||
|       final vm = Provider.of<StateViewModelScreen>(context, listen: false); | ||||
|       vm.refreshData(); | ||||
|     }); | ||||
|   } | ||||
| 
 | ||||
|   void _navigateToUpdateScreen(Map<String, dynamic> entity) { | ||||
|     Navigator.push( | ||||
|       context, | ||||
|       MaterialPageRoute( | ||||
|         builder: (context) => ChangeNotifierProvider( | ||||
|           create: (context) => StateViewModelScreen(), | ||||
|           child: StateUpdateEntityScreen(entity: entity), | ||||
|         ), | ||||
|       ), | ||||
|     ).then((_) { | ||||
|       final vm = Provider.of<StateViewModelScreen>(context, listen: false); | ||||
|       vm.refreshData(); | ||||
|     }); | ||||
|   } | ||||
| 
 | ||||
|   void _navigateToDetailsScreen(Map<String, dynamic> entity) { | ||||
|     Navigator.push( | ||||
|       context, | ||||
|       MaterialPageRoute( | ||||
|         builder: (context) => ChangeNotifierProvider( | ||||
|           create: (context) => StateViewModelScreen(), | ||||
|           child: StateDetailsScreen(entity: entity), | ||||
|         ), | ||||
|       ), | ||||
|     ); | ||||
|   } | ||||
| 
 | ||||
|   void _showDeleteDialog(Map<String, dynamic> entity) { | ||||
|  final parentContext = context;  | ||||
|     showDialog( | ||||
|       context: context, | ||||
|       builder: (BuildContext context) { | ||||
|         return AlertDialog( | ||||
|           title: const Text('Confirm Deletion'), | ||||
|           content: const Text('Are you sure you want to delete this State?'), | ||||
|           actions: [ | ||||
|             TextButton( | ||||
|               child: const Text('Cancel'), | ||||
|               onPressed: () { | ||||
|                 Navigator.of(context).pop(); | ||||
|               }, | ||||
|             ), | ||||
|             TextButton( | ||||
|               child: const Text('Delete'), | ||||
|               onPressed: () async { | ||||
|                 Navigator.of(context).pop(); | ||||
|                 final vm = | ||||
|                     Provider.of<StateViewModelScreen>(parentContext, listen: false); | ||||
|                 await vm.deleteEntity(entity['id']); | ||||
|               }, | ||||
|             ), | ||||
|           ], | ||||
|         ); | ||||
|       }, | ||||
|     ); | ||||
|   } | ||||
| 
 | ||||
|   @override | ||||
|   Widget build(BuildContext context) { | ||||
|     return Consumer<StateViewModelScreen>( | ||||
|       builder: (context, viewModel, child) { | ||||
|         return EntityList( | ||||
|           entities: viewModel.filteredList, | ||||
|           isLoading: viewModel.isLoading, | ||||
|           errorMessage: | ||||
|               viewModel.errorMessage.isNotEmpty ? viewModel.errorMessage : null, | ||||
|           hasMoreData: viewModel.hasMoreData, | ||||
|           searchQuery: viewModel.searchQuery, | ||||
|           onSearchChanged: (query) => viewModel.searchstate(query), | ||||
|           onEdit: (entity) => _navigateToUpdateScreen(entity), | ||||
|           onDelete: (entity) => _showDeleteDialog(entity), | ||||
|           onTap: (entity) => _navigateToDetailsScreen(entity), | ||||
|           onRefresh: () => viewModel.refreshData(), | ||||
|           onLoadMore: () => viewModel.getAllWithPagination(), | ||||
|           title: 'State', | ||||
|           onAddNew: _navigateToCreateScreen, | ||||
|           displayFields: [ | ||||
|   {'key': 'state_name', 'label': 'state name', 'type': 'text'}, | ||||
| 
 | ||||
|   {'key': 'description', 'label': 'Description', 'type': 'textarea'}, | ||||
| 
 | ||||
|   {'key': 'active', 'label': 'Active', 'type': 'toggle_switch'}, | ||||
| 
 | ||||
|   {'key': 'country_name', 'label': 'country name', 'type': 'text'}, | ||||
| 
 | ||||
|           ], | ||||
|         ); | ||||
|       }, | ||||
|     ); | ||||
|   } | ||||
| } | ||||
| @ -0,0 +1,84 @@ | ||||
| import 'package:base_project/BuilderField/shared/fields/number_field.dart'; | ||||
| import 'package:base_project/BuilderField/shared/fields/password_field.dart'; | ||||
| import 'package:base_project/BuilderField/shared/fields/phone_field.dart'; | ||||
| import 'package:base_project/BuilderField/shared/fields/custom_text_field.dart'; | ||||
| 
 | ||||
| import '../../../../BuilderField/shared/fields/base_field.dart'; | ||||
| 
 | ||||
| import '../../../../BuilderField/shared/fields/date_field.dart'; | ||||
| import '../../../../BuilderField/shared/fields/datetime_field.dart'; | ||||
| import '../../../../BuilderField/shared/fields/email_field.dart'; | ||||
| import 'package:base_project/BuilderField/shared/fields/url_field.dart'; | ||||
| import 'package:flutter/material.dart'; | ||||
| import 'package:provider/provider.dart'; | ||||
| 
 | ||||
| import '../../../../BuilderField/shared/fields/custom_text_field.dart' as shared_text; | ||||
| import '../../../../BuilderField/shared/fields/one_to_one_relation_field.dart'; | ||||
| import '../../../../BuilderField/shared/fields/calculated_field.dart'; | ||||
| import '../../../../BuilderField/shared/fields/one_to_many_field.dart'; | ||||
| import '../../../../BuilderField/shared/fields/value_list_picker_field.dart'; | ||||
| import '../../../../BuilderField/shared/fields/captcha_field.dart'; | ||||
| import '../../../../BuilderField/shared/fields/switch_field.dart'; | ||||
| import '../../../../BuilderField/shared/fields/url_field.dart'; | ||||
| 
 | ||||
| import '../../../../BuilderField/shared/fields/audio_upload_field.dart'; | ||||
| import '../../../../BuilderField/shared/fields/checkbox_field.dart'; | ||||
| import '../../../../BuilderField/shared/fields/file_upload_field.dart'; | ||||
| import '../../../../BuilderField/shared/fields/image_upload_field.dart'; | ||||
| import '../../../../BuilderField/shared/fields/radio_field.dart'; | ||||
| import '../../../../BuilderField/shared/fields/video_upload_field.dart'; | ||||
| 
 | ||||
| import '../../../../BuilderField/shared/fields/autocomplete_dropdown_field.dart'; | ||||
| import '../../../../BuilderField/shared/fields/autocomplete_multiselect_field.dart'; | ||||
| import '../../../../BuilderField/shared/fields/one_to_one_relation_field.dart'; | ||||
| import '../../../../BuilderField/shared/fields/data_grid_field.dart'; | ||||
| import '../../../../BuilderField/shared/fields/dropdown_field.dart'; | ||||
| import '../../../../BuilderField/shared/fields/dynamic_dropdown_field.dart'; | ||||
| import '../../../../BuilderField/shared/fields/dynamic_multiselect_dropdown_field.dart'; | ||||
| import '../../../../BuilderField/shared/fields/static_multiselect_field.dart'; | ||||
| import '../../../../BuilderField/shared/fields/currency_field.dart'; | ||||
| import '../../../../BuilderField/shared/fields/field_group_field.dart'; | ||||
| import '../../../../BuilderField/shared/fields/qr_code_field.dart'; | ||||
| import '../../../../BuilderField/shared/fields/barcode_field.dart'; | ||||
| import '../../../../BuilderField/shared/fields/dependent_dropdown_field.dart'; | ||||
|  import '../State_viewModel/State_view_model_screen.dart';/// Field definitions for State entity | ||||
| /// This defines the structure and validation for State forms | ||||
| class StateFields { | ||||
|   /// Get field definitions for State entity | ||||
|   static List<BaseField> getFields(BuildContext context) { | ||||
|     final viewModel = | ||||
|         Provider.of<StateViewModelScreen>(context, listen: false); | ||||
|     return [ | ||||
|       // Basic Information | ||||
|  CustomTextField( | ||||
|         fieldKey: 'state_name', | ||||
|         label: 'state name', | ||||
|         hint: 'Enter state name', | ||||
|         isRequired: true, | ||||
|         maxLength: 50, | ||||
|       ), | ||||
| 
 | ||||
| CustomTextField( | ||||
|         fieldKey: 'description', | ||||
|         label: 'Description', | ||||
|         hint: 'Enter Description', | ||||
|         isRequired: false, | ||||
|         maxLength: 1000, | ||||
|       ), | ||||
| 
 | ||||
|  SwitchField( | ||||
|         fieldKey: 'active', | ||||
|         label: 'Active', | ||||
|       ), | ||||
| 
 | ||||
|  CustomTextField( | ||||
|         fieldKey: 'country_name', | ||||
|         label: 'country name', | ||||
|         hint: 'Enter country name', | ||||
|         isRequired: true, | ||||
|         maxLength: 50, | ||||
|       ), | ||||
| 
 | ||||
|     ]; | ||||
|   } | ||||
| } | ||||
| @ -0,0 +1,79 @@ | ||||
| // ignore_for_file: use_build_context_synchronously | ||||
| import 'dart:convert'; | ||||
| import 'package:provider/provider.dart'; | ||||
| import '../State_viewModel/State_view_model_screen.dart'; | ||||
| import 'package:base_project/BuilderField/shared/ui/entity_screens.dart'; | ||||
| import 'State_fields.dart';import '../../../../utils/image_constant.dart'; | ||||
| import '../../../../utils/size_utils.dart'; | ||||
| import '../../../../theme/app_style.dart'; | ||||
| import '../../../../widgets/app_bar/appbar_image.dart'; | ||||
| import '../../../../widgets/app_bar/appbar_title.dart'; | ||||
| import '../../../../widgets/app_bar/custom_app_bar.dart'; | ||||
| import 'package:barcode_widget/barcode_widget.dart'; | ||||
| import 'package:fluttertoast/fluttertoast.dart'; | ||||
| import '../../../../widgets/custom_button.dart'; | ||||
| import '../../../../widgets/custom_text_form_field.dart'; | ||||
| import 'package:flutter/material.dart'; | ||||
| import 'package:autocomplete_textfield/autocomplete_textfield.dart'; | ||||
| import 'package:qr_flutter/qr_flutter.dart'; | ||||
| import 'package:intl/intl.dart'; | ||||
| 
 | ||||
| import 'dart:math'; | ||||
| import '../../../../Reuseable/reusable_text_field.dart'; | ||||
| import '../../../../Reuseable/reusable_date_picker_field.dart'; | ||||
| import '../../../../Reuseable/reusable_date_time_picker_field.dart'; | ||||
| import '../../../../Reuseable/reusable_dropdown_field.dart'; | ||||
| import 'package:flutter/services.dart'; | ||||
| class StateUpdateEntityScreen extends StatefulWidget { | ||||
|     final Map<String, dynamic> entity; | ||||
| 
 | ||||
| 
 | ||||
|   StateUpdateEntityScreen({required this.entity}); | ||||
| 
 | ||||
|   @override | ||||
|   _StateUpdateEntityScreenState createState() => _StateUpdateEntityScreenState(); | ||||
| } | ||||
| 
 | ||||
| class _StateUpdateEntityScreenState extends State<StateUpdateEntityScreen> { | ||||
|   final _formKey = GlobalKey<FormState>(); | ||||
| 
 | ||||
| @override | ||||
|   Widget build(BuildContext context) { | ||||
|     return Consumer<StateViewModelScreen>( | ||||
|       builder: (context, viewModel, child) { | ||||
| // Start with all fields, then remove upload fields (generic filter by keys) | ||||
|         final Set<String> hiddenKeys = {  | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|  }; | ||||
|         final fields = StateFields.getFields(context) | ||||
|             .where((f) => !hiddenKeys.contains(f.fieldKey)) | ||||
|             .toList();        return EntityUpdateScreen( | ||||
|           fields: fields, | ||||
|           initialData: widget.entity, | ||||
|           onSubmit: (data) => _handleSubmit(data), | ||||
|           title: 'State', | ||||
|           isLoading: viewModel.isLoading, | ||||
|           errorMessage: | ||||
|               viewModel.errorMessage.isNotEmpty ? viewModel.errorMessage : null, | ||||
|         ); | ||||
|       }, | ||||
|     ); | ||||
|   } | ||||
| 
 | ||||
|   Future<void> _handleSubmit(Map<String, dynamic> formData) async { | ||||
|     final provider = | ||||
|         Provider.of<StateViewModelScreen>(context, listen: false); | ||||
|     final success = await provider.updateEntity(widget.entity['id'], formData); | ||||
| 
 | ||||
|     if (success && mounted) { | ||||
|       Navigator.pop(context); | ||||
|     } | ||||
|   } | ||||
| } | ||||
| @ -0,0 +1,97 @@ | ||||
| import 'package:dio/dio.dart'; | ||||
| import '../../../../data/network/base_network_service.dart'; | ||||
| import '../../../../data/network/network_api_service.dart'; | ||||
| import '../../../../resources/api_constants.dart'; | ||||
| import 'package:base_project/data/response/api_response.dart'; | ||||
| 
 | ||||
| class StateRepoScreen { | ||||
| 
 | ||||
|   final String baseUrl = ApiConstants.baseUrl; | ||||
|   final BaseNetworkService _helper = NetworkApiService(); | ||||
|   final String _endpointPath = '/State/State'; | ||||
| 
 | ||||
|   Future<ApiResponse<List<Map<String, dynamic>>>> getEntities() async { | ||||
|     try { | ||||
|       final response = | ||||
|           await _helper.getGetApiResponse('$baseUrl$_endpointPath'); | ||||
|       print('Response received: $response'); | ||||
|       List<Map<String, dynamic>> entities = const []; | ||||
|       if (response is List) { | ||||
|         entities = response | ||||
|             .whereType<Map>() | ||||
|             .map((e) => Map<String, dynamic>.from(e as Map)) | ||||
|             .toList(); | ||||
|       } else if (response is Map<String, dynamic>) { | ||||
|         final dynamic content = response['content']; | ||||
|         if (content is List) { | ||||
|           entities = content | ||||
|               .whereType<Map>() | ||||
|               .map((e) => Map<String, dynamic>.from(e as Map)) | ||||
|               .toList(); | ||||
|         } | ||||
|       } | ||||
|       return ApiResponse.success(entities); | ||||
|     } catch (e) { | ||||
|       print(' error got $e'); | ||||
|       return ApiResponse.error('Failed to get all entities: $e'); | ||||
|     } | ||||
|   }  | ||||
| 
 | ||||
|   Future<ApiResponse<List<Map<String, dynamic>>>> getAllWithPagination( | ||||
|       int page, int size) async { | ||||
|     try { | ||||
|       final response = await _helper.getGetApiResponse( | ||||
|           '$baseUrl$_endpointPath/getall/page?page=$page&size=$size'); | ||||
| 
 | ||||
|       if (response is Map<String, dynamic> && response['content'] is List) { | ||||
|         final List<Map<String, dynamic>> entities = | ||||
|             (response['content'] as List).cast<Map<String, dynamic>>().toList(); | ||||
|         return ApiResponse.success(entities); | ||||
|       } else { | ||||
|         return ApiResponse.error('Invalid response format'); | ||||
|       } | ||||
|     } catch (e) { | ||||
|       return ApiResponse.error('Failed to get all without pagination: $e'); | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
|   Future<ApiResponse<Map<String, dynamic>>> createEntity( | ||||
|       Map<String, dynamic> entity) async { | ||||
|     try { | ||||
|       print("in post api$entity"); | ||||
|       final response = | ||||
|           await _helper.getPostApiResponse('$baseUrl$_endpointPath', entity); | ||||
|       return ApiResponse.success(response as Map<String, dynamic>); | ||||
|     } catch (e) { | ||||
|       return ApiResponse.error('Failed to create entity: $e'); | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
|   Future<ApiResponse<Map<String, dynamic>>> updateEntity( | ||||
|       int entityId, Map<String, dynamic> entity) async { | ||||
|     try { | ||||
|       final response = await _helper.getPutApiResponse( | ||||
|           '$baseUrl$_endpointPath/$entityId', entity); | ||||
|       return ApiResponse.success(response as Map<String, dynamic>); | ||||
|     } catch (e) { | ||||
|       return ApiResponse.error('Failed to update entity: $e'); | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
|   Future<ApiResponse<void>> deleteEntity(int entityId) async { | ||||
|     try { | ||||
|       await _helper.getDeleteApiResponse('$baseUrl$_endpointPath/$entityId'); | ||||
|       return ApiResponse.success(null); | ||||
|     } catch (e) { | ||||
|       return ApiResponse.error('Failed to delete entity: $e'); | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| } | ||||
| @ -0,0 +1,321 @@ | ||||
| import 'package:base_project/data/response/status.dart'; | ||||
| import 'dart:typed_data'; | ||||
| import 'package:dio/dio.dart'; | ||||
| import 'package:http_parser/http_parser.dart'; | ||||
| import '../../../../utils/toast_messages/toast_message_util.dart'; | ||||
| import '../../../../BuilderField/shared/utils/entity_field_store.dart'; | ||||
| import 'package:flutter/material.dart'; | ||||
| import '../State_Repo/State_repo_screen.dart'; | ||||
| 
 | ||||
| class StateViewModelScreen extends ChangeNotifier{ | ||||
|   final StateRepoScreen repo = StateRepoScreen(); | ||||
| 
 | ||||
|   | ||||
|   // State variables | ||||
|   List<Map<String, dynamic>> _stateList = []; | ||||
|   List<Map<String, dynamic>> _filteredList = []; | ||||
|   bool _isLoading = false; | ||||
|   String _errorMessage = ''; | ||||
|   int _currentPage = 0; | ||||
|   int _pageSize = 10; | ||||
|   bool _hasMoreData = true; | ||||
|   String _searchQuery = ''; | ||||
| 
 | ||||
|   // Getters | ||||
|   List<Map<String, dynamic>> get stateList => _stateList; | ||||
|   List<Map<String, dynamic>> get filteredList => _filteredList; | ||||
|   bool get isLoading => _isLoading; | ||||
|   String get errorMessage => _errorMessage; | ||||
|   bool get hasMoreData => _hasMoreData; | ||||
|   String get searchQuery => _searchQuery; | ||||
| 
 | ||||
|   // Set loading state | ||||
|   void _setLoading(bool loading) { | ||||
|     _isLoading = loading; | ||||
|     notifyListeners(); | ||||
|   } | ||||
| 
 | ||||
|   // Set error message | ||||
|   void _setError(String error) { | ||||
|     _errorMessage = error; | ||||
|     notifyListeners(); | ||||
|   } | ||||
| 
 | ||||
|   // Clear error | ||||
|   void clearError() { | ||||
|     _errorMessage = ''; | ||||
|     notifyListeners(); | ||||
|   } | ||||
| 
 | ||||
|   // Get state list | ||||
|   Future<void> getEntities() async { | ||||
|     _setLoading(true); | ||||
|     _setError(''); | ||||
| 
 | ||||
|     try { | ||||
|       final response = await repo.getEntities(); | ||||
| 
 | ||||
|       if (response.status == Status.SUCCESS) { | ||||
|         _stateList = response.data ?? []; | ||||
|         _filteredList = List.from(_stateList); | ||||
|         _currentPage = 0; | ||||
|         _hasMoreData = true; | ||||
|       } else { | ||||
|         _setError(response.message ?? 'Failed to fetch state list'); | ||||
|       } | ||||
|     } catch (e) { | ||||
|       _setError('Failed to fetch state list: $e'); | ||||
|     } finally { | ||||
|       _setLoading(false); | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
|   // Get state list with pagination | ||||
|   Future<void> getAllWithPagination({bool refresh = false}) async { | ||||
|     if (refresh) { | ||||
|       _currentPage = 0; | ||||
|       _stateList.clear(); | ||||
|       _filteredList.clear(); | ||||
|       _hasMoreData = true; | ||||
|     } | ||||
| 
 | ||||
|     if (!_hasMoreData || _isLoading) return; | ||||
| 
 | ||||
|     _setLoading(true); | ||||
|     _setError(''); | ||||
| 
 | ||||
|     try { | ||||
|       final response = await repo.getAllWithPagination(_currentPage, _pageSize); | ||||
| 
 | ||||
|       if (response.status == Status.SUCCESS) { | ||||
|         final newItems = response.data ?? []; | ||||
| 
 | ||||
|         if (refresh) { | ||||
|           _stateList = newItems; | ||||
|         } else { | ||||
|           _stateList.addAll(newItems); | ||||
|         } | ||||
| 
 | ||||
|         _filteredList = List.from(_stateList); | ||||
|         _currentPage++; | ||||
| 
 | ||||
|         // Check if we have more data | ||||
|         _hasMoreData = newItems.length == _pageSize; | ||||
|       } else { | ||||
|         _setError(response.message ?? 'Failed to fetch State list'); | ||||
|       } | ||||
|     } catch (e) { | ||||
|       _setError('Failed to fetch state list: $e'); | ||||
|     } finally { | ||||
|       _setLoading(false); | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|   // Create State | ||||
|   Future<bool> createEntity(Map<String, dynamic> entity) async { | ||||
|     _setLoading(true); | ||||
|     _setError(''); | ||||
| 
 | ||||
|     try { | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|       final response = await repo.createEntity(entity); | ||||
| 
 | ||||
|       if (response.status == Status.SUCCESS) { | ||||
| // Get the response ID for image upload | ||||
| 
 | ||||
|         final responseId = response.data!['id'].toString(); | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|         ToastMessageUtil.showToast( | ||||
|           message: 'state created successfully', | ||||
|           toastType: ToastType.success, | ||||
|         ); | ||||
| 
 | ||||
|         // Refresh the list | ||||
|         await getEntities(); | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|         return true; | ||||
|       } else { | ||||
|         _setError(response.message ?? 'Failed to create State'); | ||||
|         ToastMessageUtil.showToast( | ||||
|           message: response.message ?? 'Failed to create State', | ||||
|           toastType: ToastType.error, | ||||
|         ); | ||||
|         return false; | ||||
|       } | ||||
|     } catch (e) { | ||||
|       _setError('Failed to create state: $e'); | ||||
|       ToastMessageUtil.showToast( | ||||
|         message: 'Failed to create State: $e', | ||||
|         toastType: ToastType.error, | ||||
|       ); | ||||
|       return false; | ||||
|     } finally { | ||||
|       _setLoading(false); | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
|   // Update state | ||||
|   Future<bool> updateEntity(int id, Map<String, dynamic> entity) async { | ||||
|     _setLoading(true); | ||||
|     _setError(''); | ||||
| 
 | ||||
|     try { | ||||
|       final response = await repo.updateEntity(id, entity); | ||||
| 
 | ||||
|       if (response.status == Status.SUCCESS) { | ||||
|         ToastMessageUtil.showToast( | ||||
|           message: 'State updated successfully', | ||||
|           toastType: ToastType.success, | ||||
|         ); | ||||
| 
 | ||||
|         // Update the item in the list | ||||
|         final index = _stateList.indexWhere((item) => item['id'] == id); | ||||
|         if (index != -1) { | ||||
|           _stateList[index] = response.data!; | ||||
|           _filteredList = List.from(_stateList); | ||||
|           notifyListeners(); | ||||
|         } | ||||
|         return true; | ||||
|       } else { | ||||
|         _setError(response.message ?? 'Failed to update State'); | ||||
|         ToastMessageUtil.showToast( | ||||
|           message: response.message ?? 'Failed to update State', | ||||
|           toastType: ToastType.error, | ||||
|         ); | ||||
|         return false; | ||||
|       } | ||||
|     } catch (e) { | ||||
|       _setError('Failed to update state: $e'); | ||||
|       ToastMessageUtil.showToast( | ||||
|         message: 'Failed to update State: $e', | ||||
|         toastType: ToastType.error, | ||||
|       ); | ||||
|       return false; | ||||
|     } finally { | ||||
|       _setLoading(false); | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
|   // Delete state | ||||
|   Future<bool> deleteEntity(int id) async { | ||||
|     _setLoading(true); | ||||
|     _setError(''); | ||||
| 
 | ||||
|     try { | ||||
|       final response = await repo.deleteEntity(id); | ||||
| 
 | ||||
|       if (response.status == Status.SUCCESS) { | ||||
|         ToastMessageUtil.showToast( | ||||
|           message: 'State deleted successfully', | ||||
|           toastType: ToastType.success, | ||||
|         ); | ||||
| 
 | ||||
|         // Remove the item from the list | ||||
|         _stateList.removeWhere((item) => item['id'] == id); | ||||
|         _filteredList = List.from(_stateList); | ||||
|         notifyListeners(); | ||||
|         return true; | ||||
|       } else { | ||||
|         _setError(response.message ?? 'Failed to delete State'); | ||||
|         ToastMessageUtil.showToast( | ||||
|           message: response.message ?? 'Failed to delete State', | ||||
|           toastType: ToastType.error, | ||||
|         ); | ||||
|         return false; | ||||
|       } | ||||
|     } catch (e) { | ||||
|       _setError('Failed to delete state: $e'); | ||||
|       ToastMessageUtil.showToast( | ||||
|         message: 'Failed to delete State: $e', | ||||
|         toastType: ToastType.error, | ||||
|       ); | ||||
|       return false; | ||||
|     } finally { | ||||
|       _setLoading(false); | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
|   // Search state | ||||
|   void searchstate(String query) { | ||||
|     _searchQuery = query; | ||||
| 
 | ||||
|     if (query.isEmpty) { | ||||
|       _filteredList = List.from(_stateList); | ||||
|     } else { | ||||
|       _filteredList = _stateList.where((item) { | ||||
|         return | ||||
| 
 | ||||
|               | ||||
| (item['state_name']?.toString().toLowerCase().contains(query.toLowerCase()) ??false) || | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|               | ||||
| (item['description']?.toString().toLowerCase().contains(query.toLowerCase()) ??false) || | ||||
| 
 | ||||
| 
 | ||||
| (item['active']?.toString().toLowerCase().contains(query.toLowerCase()) ??false) || | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|               | ||||
| (item['country_name']?.toString().toLowerCase().contains(query.toLowerCase()) ??false)  | ||||
| 
 | ||||
| 
 | ||||
| ; | ||||
|       }).toList(); | ||||
|     } | ||||
|     notifyListeners(); | ||||
|   } | ||||
| 
 | ||||
|   // Clear search | ||||
|   void clearSearch() { | ||||
|     _searchQuery = ''; | ||||
|     _filteredList = List.from(_stateList); | ||||
|     notifyListeners(); | ||||
|   } | ||||
| 
 | ||||
|   // Refresh data | ||||
|   Future<void> refreshData() async { | ||||
|     await getAllWithPagination(refresh: true); | ||||
|   } | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| } | ||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @ -69,6 +69,18 @@ public class BuilderService { | ||||
| 		executeDump(true); | ||||
| 
 | ||||
| 		// ADD OTHER SERVICE | ||||
| addCustomMenu( "District","District",  "Transcations");  | ||||
| 
 | ||||
| 
 | ||||
| addCustomMenu( "State","State",  "Transcations");  | ||||
| 
 | ||||
| 
 | ||||
| addCustomMenu( "Country","Country",  "Transcations");  | ||||
| 
 | ||||
| 
 | ||||
| addCustomMenu( "Ad6","Ad6",  "Transcations");  | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 		System.out.println("dashboard and menu inserted..."); | ||||
| 
 | ||||
|  | ||||
| @ -0,0 +1,115 @@ | ||||
| package com.realnet.angulardatatype.Controllers; | ||||
| import java.util.List; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | ||||
|  import org.springframework.web.bind.annotation.*; | ||||
| import org.springframework.web.multipart.MultipartFile; | ||||
| import com.fasterxml.jackson.core.JsonProcessingException; | ||||
| import org.springframework.web.bind.annotation.CrossOrigin; | ||||
| import com.fasterxml.jackson.databind.JsonMappingException; | ||||
| import com.realnet.config.EmailService; | ||||
| import com.realnet.users.entity1.AppUser; | ||||
| import com.realnet.users.service1.AppUserServiceImpl; | ||||
| import com.fasterxml.jackson.databind.ObjectMapper; | ||||
| import org.springframework.data.domain.*; | ||||
| import com.realnet.fnd.response.EntityResponse; | ||||
| import org.springframework.http.*; | ||||
| import org.springframework.beans.factory.annotation.*; | ||||
| import com.realnet.angulardatatype.Entity.Ad6; | ||||
| import com.realnet.angulardatatype.Services.Ad6Service ; | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| @RequestMapping(value = "/Ad6") | ||||
|  @CrossOrigin("*")  | ||||
| @RestController | ||||
| public class Ad6Controller { | ||||
| 	@Autowired | ||||
| 	private Ad6Service Service; | ||||
| 
 | ||||
| @Value("${projectPath}") | ||||
| 	private String projectPath; | ||||
|   | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 	@PostMapping("/Ad6") | ||||
| 		  public Ad6 Savedata(@RequestBody Ad6 data) { | ||||
| 		Ad6 save = Service.Savedata(data)	; | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 		System.out.println("data saved..." + save); | ||||
| 
 | ||||
|  return save; | ||||
| 	  } | ||||
| @PutMapping("/Ad6/{id}") | ||||
| 	public  Ad6 update(@RequestBody Ad6 data,@PathVariable Integer id ) { | ||||
| 		Ad6 update = Service.update(data,id); | ||||
| 		System.out.println("data update..." + update); | ||||
| 		return update; | ||||
| 	}	  | ||||
| //	get all with pagination | ||||
| 	@GetMapping("/Ad6/getall/page") | ||||
| 	public Page<Ad6> getall(@RequestParam(value = "page", required = false) Integer page, | ||||
| 			@RequestParam(value = "size", required = false) Integer size) { | ||||
| 		Pageable paging = PageRequest.of(page, size); | ||||
| 		Page<Ad6> get = Service.getAllWithPagination(paging); | ||||
| 
 | ||||
| 		return get; | ||||
| 
 | ||||
| 	}	 | ||||
| 	@GetMapping("/Ad6") | ||||
| 	public List<Ad6> getdetails() { | ||||
| 		 List<Ad6> get = Service.getdetails();		 | ||||
| 		return get; | ||||
| } | ||||
| // get all without authentication  | ||||
| 
 | ||||
| 	@GetMapping("/token/Ad6") | ||||
| 	public List<Ad6> getallwioutsec() { | ||||
| 		 List<Ad6> get = Service.getdetails();		 | ||||
| 		return get; | ||||
| } | ||||
| @GetMapping("/Ad6/{id}") | ||||
| 	public  Ad6  getdetailsbyId(@PathVariable Integer id ) { | ||||
| 		Ad6  get = Service.getdetailsbyId(id); | ||||
| 		return get; | ||||
| 	} | ||||
| @DeleteMapping("/Ad6/{id}") | ||||
| 	public  ResponseEntity<?> delete_by_id(@PathVariable Integer id ) { | ||||
| 	Service.delete_by_id(id); | ||||
| 			return new ResponseEntity<>(new EntityResponse("Deleted"), HttpStatus.OK); | ||||
| 	 | ||||
| 	} | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| } | ||||
| @ -0,0 +1,24 @@ | ||||
| package com.realnet.angulardatatype.Controllers; | ||||
| import java.util.List; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | ||||
|  import org.springframework.web.bind.annotation.*; | ||||
| import com.realnet.angulardatatype.Entity.District_ListFilter1; | ||||
| import com.realnet.angulardatatype.Services.District_ListFilter1Service ; | ||||
| @RequestMapping(value = "/District_ListFilter1") | ||||
| @RestController | ||||
| public class District_ListFilter1Controller { | ||||
| 	 | ||||
| 	@Autowired | ||||
| 	private District_ListFilter1Service Service; | ||||
| 
 | ||||
| 		@GetMapping("/District_ListFilter1") | ||||
| 	public List<District_ListFilter1> getlist() { | ||||
| 		 List<District_ListFilter1> get = Service.getlistbuilder();		 | ||||
| 		return get; | ||||
| } | ||||
| 		@GetMapping("/District_ListFilter11/{item}") | ||||
| 	public List<District_ListFilter1> getlistwithparam(  @PathVariable String item) { | ||||
| 		 List<District_ListFilter1> get = Service.getlistbuilderparam(  item);		 | ||||
| 		return get; | ||||
| } | ||||
| } | ||||
| @ -0,0 +1,24 @@ | ||||
| package com.realnet.angulardatatype.Controllers; | ||||
| import java.util.List; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | ||||
|  import org.springframework.web.bind.annotation.*; | ||||
| import com.realnet.angulardatatype.Entity.State_ListFilter1; | ||||
| import com.realnet.angulardatatype.Services.State_ListFilter1Service ; | ||||
| @RequestMapping(value = "/State_ListFilter1") | ||||
| @RestController | ||||
| public class State_ListFilter1Controller { | ||||
| 	 | ||||
| 	@Autowired | ||||
| 	private State_ListFilter1Service Service; | ||||
| 
 | ||||
| 		@GetMapping("/State_ListFilter1") | ||||
| 	public List<State_ListFilter1> getlist() { | ||||
| 		 List<State_ListFilter1> get = Service.getlistbuilder();		 | ||||
| 		return get; | ||||
| } | ||||
| 		@GetMapping("/State_ListFilter11/{item}") | ||||
| 	public List<State_ListFilter1> getlistwithparam(  @PathVariable String item) { | ||||
| 		 List<State_ListFilter1> get = Service.getlistbuilderparam(  item);		 | ||||
| 		return get; | ||||
| } | ||||
| } | ||||
| @ -0,0 +1,115 @@ | ||||
| package com.realnet.angulardatatype.Controllers; | ||||
| import java.util.List; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | ||||
|  import org.springframework.web.bind.annotation.*; | ||||
| import org.springframework.web.multipart.MultipartFile; | ||||
| import com.fasterxml.jackson.core.JsonProcessingException; | ||||
| import org.springframework.web.bind.annotation.CrossOrigin; | ||||
| import com.fasterxml.jackson.databind.JsonMappingException; | ||||
| import com.realnet.config.EmailService; | ||||
| import com.realnet.users.entity1.AppUser; | ||||
| import com.realnet.users.service1.AppUserServiceImpl; | ||||
| import com.fasterxml.jackson.databind.ObjectMapper; | ||||
| import org.springframework.data.domain.*; | ||||
| import com.realnet.fnd.response.EntityResponse; | ||||
| import org.springframework.http.*; | ||||
| import org.springframework.beans.factory.annotation.*; | ||||
| import com.realnet.angulardatatype.Entity.Ad6; | ||||
| import com.realnet.angulardatatype.Services.Ad6Service ; | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| @RequestMapping(value = "/token/Ad6") | ||||
|  @CrossOrigin("*")  | ||||
| @RestController | ||||
| public class tokenFree_Ad6Controller { | ||||
| 	@Autowired | ||||
| 	private Ad6Service Service; | ||||
| 
 | ||||
| @Value("${projectPath}") | ||||
| 	private String projectPath; | ||||
|   | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 	@PostMapping("/Ad6") | ||||
| 		  public Ad6 Savedata(@RequestBody Ad6 data) { | ||||
| 		Ad6 save = Service.Savedata(data)	; | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 		System.out.println("data saved..." + save); | ||||
| 
 | ||||
|  return save; | ||||
| 	  } | ||||
| @PutMapping("/Ad6/{id}") | ||||
| 	public  Ad6 update(@RequestBody Ad6 data,@PathVariable Integer id ) { | ||||
| 		Ad6 update = Service.update(data,id); | ||||
| 		System.out.println("data update..." + update); | ||||
| 		return update; | ||||
| 	}	  | ||||
| //	get all with pagination | ||||
| 	@GetMapping("/Ad6/getall/page") | ||||
| 	public Page<Ad6> getall(@RequestParam(value = "page", required = false) Integer page, | ||||
| 			@RequestParam(value = "size", required = false) Integer size) { | ||||
| 		Pageable paging = PageRequest.of(page, size); | ||||
| 		Page<Ad6> get = Service.getAllWithPagination(paging); | ||||
| 
 | ||||
| 		return get; | ||||
| 
 | ||||
| 	}	 | ||||
| 	@GetMapping("/Ad6") | ||||
| 	public List<Ad6> getdetails() { | ||||
| 		 List<Ad6> get = Service.getdetails();		 | ||||
| 		return get; | ||||
| } | ||||
| // get all without authentication  | ||||
| 
 | ||||
| 	@GetMapping("/token/Ad6") | ||||
| 	public List<Ad6> getallwioutsec() { | ||||
| 		 List<Ad6> get = Service.getdetails();		 | ||||
| 		return get; | ||||
| } | ||||
| @GetMapping("/Ad6/{id}") | ||||
| 	public  Ad6  getdetailsbyId(@PathVariable Integer id ) { | ||||
| 		Ad6  get = Service.getdetailsbyId(id); | ||||
| 		return get; | ||||
| 	} | ||||
| @DeleteMapping("/Ad6/{id}") | ||||
| 	public  ResponseEntity<?> delete_by_id(@PathVariable Integer id ) { | ||||
| 	Service.delete_by_id(id); | ||||
| 			return new ResponseEntity<>(new EntityResponse("Deleted"), HttpStatus.OK); | ||||
| 	 | ||||
| 	} | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| } | ||||
| @ -0,0 +1,24 @@ | ||||
| package com.realnet.angulardatatype.Controllers; | ||||
| import java.util.List; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | ||||
|  import org.springframework.web.bind.annotation.*; | ||||
| import com.realnet.angulardatatype.Entity.District_ListFilter1; | ||||
| import com.realnet.angulardatatype.Services.District_ListFilter1Service ; | ||||
| @RequestMapping(value = "/token/District_ListFilter1") | ||||
| @RestController | ||||
| public class tokenFree_District_ListFilter1Controller { | ||||
| 	 | ||||
| 	@Autowired | ||||
| 	private District_ListFilter1Service Service; | ||||
| 
 | ||||
| 		@GetMapping("/District_ListFilter1") | ||||
| 	public List<District_ListFilter1> getlist() { | ||||
| 		 List<District_ListFilter1> get = Service.getlistbuilder();		 | ||||
| 		return get; | ||||
| } | ||||
| 		@GetMapping("/District_ListFilter11/{item}") | ||||
| 	public List<District_ListFilter1> getlistwithparam(  @PathVariable String item) { | ||||
| 		 List<District_ListFilter1> get = Service.getlistbuilderparam(  item);		 | ||||
| 		return get; | ||||
| } | ||||
| } | ||||
| @ -0,0 +1,24 @@ | ||||
| package com.realnet.angulardatatype.Controllers; | ||||
| import java.util.List; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | ||||
|  import org.springframework.web.bind.annotation.*; | ||||
| import com.realnet.angulardatatype.Entity.State_ListFilter1; | ||||
| import com.realnet.angulardatatype.Services.State_ListFilter1Service ; | ||||
| @RequestMapping(value = "/token/State_ListFilter1") | ||||
| @RestController | ||||
| public class tokenFree_State_ListFilter1Controller { | ||||
| 	 | ||||
| 	@Autowired | ||||
| 	private State_ListFilter1Service Service; | ||||
| 
 | ||||
| 		@GetMapping("/State_ListFilter1") | ||||
| 	public List<State_ListFilter1> getlist() { | ||||
| 		 List<State_ListFilter1> get = Service.getlistbuilder();		 | ||||
| 		return get; | ||||
| } | ||||
| 		@GetMapping("/State_ListFilter11/{item}") | ||||
| 	public List<State_ListFilter1> getlistwithparam(  @PathVariable String item) { | ||||
| 		 List<State_ListFilter1> get = Service.getlistbuilderparam(  item);		 | ||||
| 		return get; | ||||
| } | ||||
| } | ||||
| @ -0,0 +1,49 @@ | ||||
| package com.realnet.angulardatatype.Entity; | ||||
|  import lombok.*; | ||||
| import com.realnet.WhoColumn.Entity.Extension;  | ||||
|  import javax.persistence.*; | ||||
|  import java.time.LocalDateTime; | ||||
|  import java.util.*; | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|  @Entity  | ||||
|  @Data | ||||
|  public class    Ad6 extends Extension {  | ||||
|  /** | ||||
| 	 *  | ||||
| 	 */ | ||||
| 	private static final long serialVersionUID = 1L; | ||||
| 
 | ||||
|  @Id | ||||
|  @GeneratedValue(strategy = GenerationType.IDENTITY) | ||||
|  private Integer id; | ||||
| 
 | ||||
| private String  name; | ||||
| 
 | ||||
| private String  description; | ||||
| 
 | ||||
| private String country; | ||||
| private String countryidentifier; | ||||
| 
 | ||||
| private String state; | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| private String district; | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| } | ||||
| @ -0,0 +1,14 @@ | ||||
| package com.realnet.angulardatatype.Entity; | ||||
|  import lombok.*; | ||||
|  import javax.persistence.*; | ||||
|  import java.time.LocalDateTime; | ||||
|  import java.util.*; | ||||
| 
 | ||||
|  @Data | ||||
|  public class    District_ListFilter1 {  | ||||
| 
 | ||||
|  private Integer id; | ||||
| 
 | ||||
| 
 | ||||
|  private String district_name; | ||||
| } | ||||
| @ -0,0 +1,14 @@ | ||||
| package com.realnet.angulardatatype.Entity; | ||||
|  import lombok.*; | ||||
|  import javax.persistence.*; | ||||
|  import java.time.LocalDateTime; | ||||
|  import java.util.*; | ||||
| 
 | ||||
|  @Data | ||||
|  public class    State_ListFilter1 {  | ||||
| 
 | ||||
|  private Integer id; | ||||
| 
 | ||||
| 
 | ||||
|  private String state_name; | ||||
| } | ||||
| @ -0,0 +1,34 @@ | ||||
| package com.realnet.angulardatatype.Repository; | ||||
| 
 | ||||
| 
 | ||||
| import org.springframework.data.domain.Page; | ||||
| import org.springframework.data.domain.Pageable; | ||||
| import org.springframework.data.jpa.repository.JpaRepository; | ||||
| import org.springframework.data.jpa.repository.Query; | ||||
| 
 | ||||
| import org.springframework.stereotype.Repository;  | ||||
| import java.util.*; | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|   | ||||
| 
 | ||||
| import com.realnet.angulardatatype.Entity.Ad6; | ||||
| 
 | ||||
| @Repository | ||||
| public interface  Ad6Repository  extends  JpaRepository<Ad6, Integer>  {  | ||||
| 
 | ||||
| @Query(value = "select * from ad6 where  created_by=?1", nativeQuery = true) | ||||
| 	List<Ad6> findAll(Long creayedBy); | ||||
| 
 | ||||
| @Query(value = "select * from ad6 where  created_by=?1", nativeQuery = true) | ||||
| 	Page<Ad6> findAll( Long creayedBy,Pageable page); | ||||
| } | ||||
| @ -0,0 +1,142 @@ | ||||
| package com.realnet.angulardatatype.Services; | ||||
| import com.realnet.angulardatatype.Repository.Ad6Repository; | ||||
| import com.realnet.angulardatatype.Entity.Ad6 | ||||
| ;import java.util.*; | ||||
| 
 | ||||
| import org.springframework.beans.factory.annotation.Autowired; | ||||
| import com.realnet.SequenceGenerator.Service.SequenceService; | ||||
| import org.springframework.data.domain.Page; | ||||
| import com.realnet.realm.Entity.Realm; | ||||
| import com.realnet.realm.Services.RealmService; | ||||
| import org.springframework.data.domain.Pageable; | ||||
| import org.springframework.http.*; | ||||
| import com.realnet.users.service1.AppUserServiceImpl; | ||||
| import com.realnet.users.entity1.AppUser; | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| import com.realnet.testdata.Entity.Country; | ||||
| import com.realnet.testdata.Services.CountryService; | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 	import org.springframework.stereotype.Service; | ||||
| 
 | ||||
| @Service | ||||
|  public class Ad6Service { | ||||
| @Autowired | ||||
| private Ad6Repository Repository; | ||||
| 	@Autowired | ||||
| 	private AppUserServiceImpl userService;  | ||||
| @Autowired | ||||
| 	private RealmService realmService; | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| @Autowired | ||||
| 	private CountryService countryserv; | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| public Ad6 Savedata(Ad6 data) { | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|   | ||||
| if (data.getCountry() != null) { | ||||
| 		try {	 | ||||
|   int countryId = Integer.valueOf(data.getCountry()); | ||||
| Country get =  countryserv.getdetailsbyId(countryId); | ||||
| 			if (get != null) { | ||||
| 
 | ||||
| 			data.setCountryidentifier(get.getName()); | ||||
| } | ||||
| } catch (NumberFormatException e) { | ||||
| 				System.out.println(" countryId is not integer.."); | ||||
| 				// Invalid integer string — ignore or log | ||||
| data.setCountryidentifier(data.getCountry()); | ||||
| 			} | ||||
| 
 | ||||
| 		} | ||||
| 
 | ||||
|   | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 	data.setUpdatedBy(getUser().getUserId()); | ||||
| 		data.setCreatedBy(getUser().getUserId()); | ||||
| 		data.setAccountId(getUser().getAccount().getAccount_id()); | ||||
| Ad6 save = Repository.save(data); | ||||
| 				return save;	 | ||||
| 			} | ||||
| 
 | ||||
| 
 | ||||
| //	get all with pagination | ||||
| 	public Page<Ad6> getAllWithPagination(Pageable page) { | ||||
| 		return Repository.findAll( getUser().getUserId(),page); | ||||
| 	}			 | ||||
| public List<Ad6> getdetails() {   | ||||
| 		List<Realm> realm = realmService.findByUserId(getUser().getUserId()); | ||||
| List<Ad6> all = Repository.findAll(getUser().getUserId()); | ||||
| 		 | ||||
| 		return all ;		} | ||||
| 
 | ||||
| 
 | ||||
| public Ad6 getdetailsbyId(Integer id) { | ||||
| 	return Repository.findById(id).get(); | ||||
| 			} | ||||
| 
 | ||||
| 
 | ||||
| 	public void delete_by_id(Integer id) { | ||||
|  Repository.deleteById(id); | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| public Ad6 update(Ad6 data,Integer id) { | ||||
| 	Ad6 old = Repository.findById(id).get(); | ||||
| old.setName(data.getName()); | ||||
| 
 | ||||
| old.setDescription(data.getDescription()); | ||||
| 
 | ||||
| old.setCountry(data.getCountry()); | ||||
| 
 | ||||
| old.setState(data.getState()); | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| old.setDistrict(data.getDistrict()); | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| final Ad6 test = Repository.save(old); | ||||
| 		data.setUpdatedBy(getUser().getUserId()); | ||||
|   return test;}  | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|  public AppUser getUser() { | ||||
| 		AppUser user = userService.getLoggedInUser(); | ||||
| 		return user; | ||||
| 
 | ||||
| 	}} | ||||
| @ -0,0 +1,57 @@ | ||||
| package com.realnet.angulardatatype.Services; | ||||
| import java.util.*; | ||||
| import com.realnet.testdata.Repository.DistrictRepository; | ||||
| import com.realnet.testdata.Entity.District; | ||||
| 
 | ||||
| import com.realnet.angulardatatype.Entity.District_ListFilter1; | ||||
| import java.util.List; | ||||
| 
 | ||||
| import org.springframework.beans.factory.annotation.Autowired; | ||||
| 	import org.springframework.stereotype.Service; | ||||
| 
 | ||||
| @Service | ||||
|  public class District_ListFilter1Service { | ||||
| @Autowired | ||||
| private DistrictRepository Repository; | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|  public   List<District_ListFilter1>   getlistbuilder() { | ||||
| 	List<District> list= Repository.findAll(); | ||||
| 		ArrayList<District_ListFilter1> l = new ArrayList<>(); | ||||
| 		for (District data : list) { | ||||
| Boolean isActive = data.getActive(); | ||||
| 
 | ||||
| 				if (Boolean.TRUE.equals(isActive)) {String State_name = data.getState_name(); | ||||
|  System.out.println(State_name + "\n"); | ||||
| 
 | ||||
| 			if ("item".equals(State_name)){	 | ||||
| District_ListFilter1 dummy = new District_ListFilter1(); | ||||
| 			dummy.setId(data.getId()); | ||||
|   dummy.setDistrict_name(data.getDistrict_name()); | ||||
| 	l.add(dummy); | ||||
| }}  | ||||
| } 		 | ||||
| return l;} | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|  public   List<District_ListFilter1>   getlistbuilderparam(  String item) { | ||||
| 	List<District> list= Repository.findAll(); | ||||
| 		ArrayList<District_ListFilter1> l = new ArrayList<>(); | ||||
| 		for (District data : list) { | ||||
| Boolean isActive = data.getActive(); | ||||
| 
 | ||||
| 				if (Boolean.TRUE.equals(isActive)) {String State_name = data.getState_name(); | ||||
|  System.out.println(State_name + "\n"); | ||||
| 
 | ||||
| 			if (item.equals(State_name)){	 | ||||
| District_ListFilter1 dummy = new District_ListFilter1(); | ||||
| 			dummy.setId(data.getId()); | ||||
|   dummy.setDistrict_name(data.getDistrict_name()); | ||||
| 	l.add(dummy); | ||||
| }}  | ||||
| } 		 | ||||
| return l;} | ||||
| } | ||||
| @ -0,0 +1,57 @@ | ||||
| package com.realnet.angulardatatype.Services; | ||||
| import java.util.*; | ||||
| import com.realnet.testdata.Repository.StateRepository; | ||||
| import com.realnet.testdata.Entity.State; | ||||
| 
 | ||||
| import com.realnet.angulardatatype.Entity.State_ListFilter1; | ||||
| import java.util.List; | ||||
| 
 | ||||
| import org.springframework.beans.factory.annotation.Autowired; | ||||
| 	import org.springframework.stereotype.Service; | ||||
| 
 | ||||
| @Service | ||||
|  public class State_ListFilter1Service { | ||||
| @Autowired | ||||
| private StateRepository Repository; | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|  public   List<State_ListFilter1>   getlistbuilder() { | ||||
| 	List<State> list= Repository.findAll(); | ||||
| 		ArrayList<State_ListFilter1> l = new ArrayList<>(); | ||||
| 		for (State data : list) { | ||||
| Boolean isActive = data.getActive(); | ||||
| 
 | ||||
| 				if (Boolean.TRUE.equals(isActive)) {String Country_name = data.getCountry_name(); | ||||
|  System.out.println(Country_name + "\n"); | ||||
| 
 | ||||
| 			if ("item".equals(Country_name)){	 | ||||
| State_ListFilter1 dummy = new State_ListFilter1(); | ||||
| 			dummy.setId(data.getId()); | ||||
|   dummy.setState_name(data.getState_name()); | ||||
| 	l.add(dummy); | ||||
| }}  | ||||
| } 		 | ||||
| return l;} | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|  public   List<State_ListFilter1>   getlistbuilderparam(  String item) { | ||||
| 	List<State> list= Repository.findAll(); | ||||
| 		ArrayList<State_ListFilter1> l = new ArrayList<>(); | ||||
| 		for (State data : list) { | ||||
| Boolean isActive = data.getActive(); | ||||
| 
 | ||||
| 				if (Boolean.TRUE.equals(isActive)) {String Country_name = data.getCountry_name(); | ||||
|  System.out.println(Country_name + "\n"); | ||||
| 
 | ||||
| 			if (item.equals(Country_name)){	 | ||||
| State_ListFilter1 dummy = new State_ListFilter1(); | ||||
| 			dummy.setId(data.getId()); | ||||
|   dummy.setState_name(data.getState_name()); | ||||
| 	l.add(dummy); | ||||
| }}  | ||||
| } 		 | ||||
| return l;} | ||||
| } | ||||
| @ -0,0 +1,99 @@ | ||||
| package com.realnet.testdata.Controllers; | ||||
| import java.util.List; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | ||||
|  import org.springframework.web.bind.annotation.*; | ||||
| import org.springframework.web.multipart.MultipartFile; | ||||
| import com.fasterxml.jackson.core.JsonProcessingException; | ||||
| import org.springframework.web.bind.annotation.CrossOrigin; | ||||
| import com.fasterxml.jackson.databind.JsonMappingException; | ||||
| import com.realnet.config.EmailService; | ||||
| import com.realnet.users.entity1.AppUser; | ||||
| import com.realnet.users.service1.AppUserServiceImpl; | ||||
| import com.fasterxml.jackson.databind.ObjectMapper; | ||||
| import org.springframework.data.domain.*; | ||||
| import com.realnet.fnd.response.EntityResponse; | ||||
| import org.springframework.http.*; | ||||
| import org.springframework.beans.factory.annotation.*; | ||||
| import com.realnet.testdata.Entity.Country; | ||||
| import com.realnet.testdata.Services.CountryService ; | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| @RequestMapping(value = "/Country") | ||||
|  @CrossOrigin("*")  | ||||
| @RestController | ||||
| public class CountryController { | ||||
| 	@Autowired | ||||
| 	private CountryService Service; | ||||
| 
 | ||||
| @Value("${projectPath}") | ||||
| 	private String projectPath; | ||||
|   | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 	@PostMapping("/Country") | ||||
| 		  public Country Savedata(@RequestBody Country data) { | ||||
| 		Country save = Service.Savedata(data)	; | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 		System.out.println("data saved..." + save); | ||||
| 
 | ||||
|  return save; | ||||
| 	  } | ||||
| @PutMapping("/Country/{id}") | ||||
| 	public  Country update(@RequestBody Country data,@PathVariable Integer id ) { | ||||
| 		Country update = Service.update(data,id); | ||||
| 		System.out.println("data update..." + update); | ||||
| 		return update; | ||||
| 	}	  | ||||
| //	get all with pagination | ||||
| 	@GetMapping("/Country/getall/page") | ||||
| 	public Page<Country> getall(@RequestParam(value = "page", required = false) Integer page, | ||||
| 			@RequestParam(value = "size", required = false) Integer size) { | ||||
| 		Pageable paging = PageRequest.of(page, size); | ||||
| 		Page<Country> get = Service.getAllWithPagination(paging); | ||||
| 
 | ||||
| 		return get; | ||||
| 
 | ||||
| 	}	 | ||||
| 	@GetMapping("/Country") | ||||
| 	public List<Country> getdetails() { | ||||
| 		 List<Country> get = Service.getdetails();		 | ||||
| 		return get; | ||||
| } | ||||
| // get all without authentication  | ||||
| 
 | ||||
| 	@GetMapping("/token/Country") | ||||
| 	public List<Country> getallwioutsec() { | ||||
| 		 List<Country> get = Service.getdetails();		 | ||||
| 		return get; | ||||
| } | ||||
| @GetMapping("/Country/{id}") | ||||
| 	public  Country  getdetailsbyId(@PathVariable Integer id ) { | ||||
| 		Country  get = Service.getdetailsbyId(id); | ||||
| 		return get; | ||||
| 	} | ||||
| @DeleteMapping("/Country/{id}") | ||||
| 	public  ResponseEntity<?> delete_by_id(@PathVariable Integer id ) { | ||||
| 	Service.delete_by_id(id); | ||||
| 			return new ResponseEntity<>(new EntityResponse("Deleted"), HttpStatus.OK); | ||||
| 	 | ||||
| 	} | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| } | ||||
| @ -0,0 +1,24 @@ | ||||
| package com.realnet.testdata.Controllers; | ||||
| import java.util.List; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | ||||
|  import org.springframework.web.bind.annotation.*; | ||||
| import com.realnet.testdata.Entity.Country_ListFilter1; | ||||
| import com.realnet.testdata.Services.Country_ListFilter1Service ; | ||||
| @RequestMapping(value = "/Country_ListFilter1") | ||||
| @RestController | ||||
| public class Country_ListFilter1Controller { | ||||
| 	 | ||||
| 	@Autowired | ||||
| 	private Country_ListFilter1Service Service; | ||||
| 
 | ||||
| 		@GetMapping("/Country_ListFilter1") | ||||
| 	public List<Country_ListFilter1> getlist() { | ||||
| 		 List<Country_ListFilter1> get = Service.getlistbuilder();		 | ||||
| 		return get; | ||||
| } | ||||
| 		@GetMapping("/Country_ListFilter11") | ||||
| 	public List<Country_ListFilter1> getlistwithparam( ) { | ||||
| 		 List<Country_ListFilter1> get = Service.getlistbuilderparam( );		 | ||||
| 		return get; | ||||
| } | ||||
| } | ||||
| @ -0,0 +1,107 @@ | ||||
| package com.realnet.testdata.Controllers; | ||||
| import java.util.List; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | ||||
|  import org.springframework.web.bind.annotation.*; | ||||
| import org.springframework.web.multipart.MultipartFile; | ||||
| import com.fasterxml.jackson.core.JsonProcessingException; | ||||
| import org.springframework.web.bind.annotation.CrossOrigin; | ||||
| import com.fasterxml.jackson.databind.JsonMappingException; | ||||
| import com.realnet.config.EmailService; | ||||
| import com.realnet.users.entity1.AppUser; | ||||
| import com.realnet.users.service1.AppUserServiceImpl; | ||||
| import com.fasterxml.jackson.databind.ObjectMapper; | ||||
| import org.springframework.data.domain.*; | ||||
| import com.realnet.fnd.response.EntityResponse; | ||||
| import org.springframework.http.*; | ||||
| import org.springframework.beans.factory.annotation.*; | ||||
| import com.realnet.testdata.Entity.District; | ||||
| import com.realnet.testdata.Services.DistrictService ; | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| @RequestMapping(value = "/District") | ||||
|  @CrossOrigin("*")  | ||||
| @RestController | ||||
| public class DistrictController { | ||||
| 	@Autowired | ||||
| 	private DistrictService Service; | ||||
| 
 | ||||
| @Value("${projectPath}") | ||||
| 	private String projectPath; | ||||
|   | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 	@PostMapping("/District") | ||||
| 		  public District Savedata(@RequestBody District data) { | ||||
| 		District save = Service.Savedata(data)	; | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 		System.out.println("data saved..." + save); | ||||
| 
 | ||||
|  return save; | ||||
| 	  } | ||||
| @PutMapping("/District/{id}") | ||||
| 	public  District update(@RequestBody District data,@PathVariable Integer id ) { | ||||
| 		District update = Service.update(data,id); | ||||
| 		System.out.println("data update..." + update); | ||||
| 		return update; | ||||
| 	}	  | ||||
| //	get all with pagination | ||||
| 	@GetMapping("/District/getall/page") | ||||
| 	public Page<District> getall(@RequestParam(value = "page", required = false) Integer page, | ||||
| 			@RequestParam(value = "size", required = false) Integer size) { | ||||
| 		Pageable paging = PageRequest.of(page, size); | ||||
| 		Page<District> get = Service.getAllWithPagination(paging); | ||||
| 
 | ||||
| 		return get; | ||||
| 
 | ||||
| 	}	 | ||||
| 	@GetMapping("/District") | ||||
| 	public List<District> getdetails() { | ||||
| 		 List<District> get = Service.getdetails();		 | ||||
| 		return get; | ||||
| } | ||||
| // get all without authentication  | ||||
| 
 | ||||
| 	@GetMapping("/token/District") | ||||
| 	public List<District> getallwioutsec() { | ||||
| 		 List<District> get = Service.getdetails();		 | ||||
| 		return get; | ||||
| } | ||||
| @GetMapping("/District/{id}") | ||||
| 	public  District  getdetailsbyId(@PathVariable Integer id ) { | ||||
| 		District  get = Service.getdetailsbyId(id); | ||||
| 		return get; | ||||
| 	} | ||||
| @DeleteMapping("/District/{id}") | ||||
| 	public  ResponseEntity<?> delete_by_id(@PathVariable Integer id ) { | ||||
| 	Service.delete_by_id(id); | ||||
| 			return new ResponseEntity<>(new EntityResponse("Deleted"), HttpStatus.OK); | ||||
| 	 | ||||
| 	} | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| } | ||||
| @ -0,0 +1,107 @@ | ||||
| package com.realnet.testdata.Controllers; | ||||
| import java.util.List; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | ||||
|  import org.springframework.web.bind.annotation.*; | ||||
| import org.springframework.web.multipart.MultipartFile; | ||||
| import com.fasterxml.jackson.core.JsonProcessingException; | ||||
| import org.springframework.web.bind.annotation.CrossOrigin; | ||||
| import com.fasterxml.jackson.databind.JsonMappingException; | ||||
| import com.realnet.config.EmailService; | ||||
| import com.realnet.users.entity1.AppUser; | ||||
| import com.realnet.users.service1.AppUserServiceImpl; | ||||
| import com.fasterxml.jackson.databind.ObjectMapper; | ||||
| import org.springframework.data.domain.*; | ||||
| import com.realnet.fnd.response.EntityResponse; | ||||
| import org.springframework.http.*; | ||||
| import org.springframework.beans.factory.annotation.*; | ||||
| import com.realnet.testdata.Entity.State; | ||||
| import com.realnet.testdata.Services.StateService ; | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| @RequestMapping(value = "/State") | ||||
|  @CrossOrigin("*")  | ||||
| @RestController | ||||
| public class StateController { | ||||
| 	@Autowired | ||||
| 	private StateService Service; | ||||
| 
 | ||||
| @Value("${projectPath}") | ||||
| 	private String projectPath; | ||||
|   | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 	@PostMapping("/State") | ||||
| 		  public State Savedata(@RequestBody State data) { | ||||
| 		State save = Service.Savedata(data)	; | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 		System.out.println("data saved..." + save); | ||||
| 
 | ||||
|  return save; | ||||
| 	  } | ||||
| @PutMapping("/State/{id}") | ||||
| 	public  State update(@RequestBody State data,@PathVariable Integer id ) { | ||||
| 		State update = Service.update(data,id); | ||||
| 		System.out.println("data update..." + update); | ||||
| 		return update; | ||||
| 	}	  | ||||
| //	get all with pagination | ||||
| 	@GetMapping("/State/getall/page") | ||||
| 	public Page<State> getall(@RequestParam(value = "page", required = false) Integer page, | ||||
| 			@RequestParam(value = "size", required = false) Integer size) { | ||||
| 		Pageable paging = PageRequest.of(page, size); | ||||
| 		Page<State> get = Service.getAllWithPagination(paging); | ||||
| 
 | ||||
| 		return get; | ||||
| 
 | ||||
| 	}	 | ||||
| 	@GetMapping("/State") | ||||
| 	public List<State> getdetails() { | ||||
| 		 List<State> get = Service.getdetails();		 | ||||
| 		return get; | ||||
| } | ||||
| // get all without authentication  | ||||
| 
 | ||||
| 	@GetMapping("/token/State") | ||||
| 	public List<State> getallwioutsec() { | ||||
| 		 List<State> get = Service.getdetails();		 | ||||
| 		return get; | ||||
| } | ||||
| @GetMapping("/State/{id}") | ||||
| 	public  State  getdetailsbyId(@PathVariable Integer id ) { | ||||
| 		State  get = Service.getdetailsbyId(id); | ||||
| 		return get; | ||||
| 	} | ||||
| @DeleteMapping("/State/{id}") | ||||
| 	public  ResponseEntity<?> delete_by_id(@PathVariable Integer id ) { | ||||
| 	Service.delete_by_id(id); | ||||
| 			return new ResponseEntity<>(new EntityResponse("Deleted"), HttpStatus.OK); | ||||
| 	 | ||||
| 	} | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| } | ||||
| @ -0,0 +1,99 @@ | ||||
| package com.realnet.testdata.Controllers; | ||||
| import java.util.List; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | ||||
|  import org.springframework.web.bind.annotation.*; | ||||
| import org.springframework.web.multipart.MultipartFile; | ||||
| import com.fasterxml.jackson.core.JsonProcessingException; | ||||
| import org.springframework.web.bind.annotation.CrossOrigin; | ||||
| import com.fasterxml.jackson.databind.JsonMappingException; | ||||
| import com.realnet.config.EmailService; | ||||
| import com.realnet.users.entity1.AppUser; | ||||
| import com.realnet.users.service1.AppUserServiceImpl; | ||||
| import com.fasterxml.jackson.databind.ObjectMapper; | ||||
| import org.springframework.data.domain.*; | ||||
| import com.realnet.fnd.response.EntityResponse; | ||||
| import org.springframework.http.*; | ||||
| import org.springframework.beans.factory.annotation.*; | ||||
| import com.realnet.testdata.Entity.Country; | ||||
| import com.realnet.testdata.Services.CountryService ; | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| @RequestMapping(value = "/token/Country") | ||||
|  @CrossOrigin("*")  | ||||
| @RestController | ||||
| public class tokenFree_CountryController { | ||||
| 	@Autowired | ||||
| 	private CountryService Service; | ||||
| 
 | ||||
| @Value("${projectPath}") | ||||
| 	private String projectPath; | ||||
|   | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 	@PostMapping("/Country") | ||||
| 		  public Country Savedata(@RequestBody Country data) { | ||||
| 		Country save = Service.Savedata(data)	; | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 		System.out.println("data saved..." + save); | ||||
| 
 | ||||
|  return save; | ||||
| 	  } | ||||
| @PutMapping("/Country/{id}") | ||||
| 	public  Country update(@RequestBody Country data,@PathVariable Integer id ) { | ||||
| 		Country update = Service.update(data,id); | ||||
| 		System.out.println("data update..." + update); | ||||
| 		return update; | ||||
| 	}	  | ||||
| //	get all with pagination | ||||
| 	@GetMapping("/Country/getall/page") | ||||
| 	public Page<Country> getall(@RequestParam(value = "page", required = false) Integer page, | ||||
| 			@RequestParam(value = "size", required = false) Integer size) { | ||||
| 		Pageable paging = PageRequest.of(page, size); | ||||
| 		Page<Country> get = Service.getAllWithPagination(paging); | ||||
| 
 | ||||
| 		return get; | ||||
| 
 | ||||
| 	}	 | ||||
| 	@GetMapping("/Country") | ||||
| 	public List<Country> getdetails() { | ||||
| 		 List<Country> get = Service.getdetails();		 | ||||
| 		return get; | ||||
| } | ||||
| // get all without authentication  | ||||
| 
 | ||||
| 	@GetMapping("/token/Country") | ||||
| 	public List<Country> getallwioutsec() { | ||||
| 		 List<Country> get = Service.getdetails();		 | ||||
| 		return get; | ||||
| } | ||||
| @GetMapping("/Country/{id}") | ||||
| 	public  Country  getdetailsbyId(@PathVariable Integer id ) { | ||||
| 		Country  get = Service.getdetailsbyId(id); | ||||
| 		return get; | ||||
| 	} | ||||
| @DeleteMapping("/Country/{id}") | ||||
| 	public  ResponseEntity<?> delete_by_id(@PathVariable Integer id ) { | ||||
| 	Service.delete_by_id(id); | ||||
| 			return new ResponseEntity<>(new EntityResponse("Deleted"), HttpStatus.OK); | ||||
| 	 | ||||
| 	} | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| } | ||||
| @ -0,0 +1,24 @@ | ||||
| package com.realnet.testdata.Controllers; | ||||
| import java.util.List; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | ||||
|  import org.springframework.web.bind.annotation.*; | ||||
| import com.realnet.testdata.Entity.Country_ListFilter1; | ||||
| import com.realnet.testdata.Services.Country_ListFilter1Service ; | ||||
| @RequestMapping(value = "/token/Country_ListFilter1") | ||||
| @RestController | ||||
| public class tokenFree_Country_ListFilter1Controller { | ||||
| 	 | ||||
| 	@Autowired | ||||
| 	private Country_ListFilter1Service Service; | ||||
| 
 | ||||
| 		@GetMapping("/Country_ListFilter1") | ||||
| 	public List<Country_ListFilter1> getlist() { | ||||
| 		 List<Country_ListFilter1> get = Service.getlistbuilder();		 | ||||
| 		return get; | ||||
| } | ||||
| 		@GetMapping("/Country_ListFilter11") | ||||
| 	public List<Country_ListFilter1> getlistwithparam( ) { | ||||
| 		 List<Country_ListFilter1> get = Service.getlistbuilderparam( );		 | ||||
| 		return get; | ||||
| } | ||||
| } | ||||
| @ -0,0 +1,107 @@ | ||||
| package com.realnet.testdata.Controllers; | ||||
| import java.util.List; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | ||||
|  import org.springframework.web.bind.annotation.*; | ||||
| import org.springframework.web.multipart.MultipartFile; | ||||
| import com.fasterxml.jackson.core.JsonProcessingException; | ||||
| import org.springframework.web.bind.annotation.CrossOrigin; | ||||
| import com.fasterxml.jackson.databind.JsonMappingException; | ||||
| import com.realnet.config.EmailService; | ||||
| import com.realnet.users.entity1.AppUser; | ||||
| import com.realnet.users.service1.AppUserServiceImpl; | ||||
| import com.fasterxml.jackson.databind.ObjectMapper; | ||||
| import org.springframework.data.domain.*; | ||||
| import com.realnet.fnd.response.EntityResponse; | ||||
| import org.springframework.http.*; | ||||
| import org.springframework.beans.factory.annotation.*; | ||||
| import com.realnet.testdata.Entity.District; | ||||
| import com.realnet.testdata.Services.DistrictService ; | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| @RequestMapping(value = "/token/District") | ||||
|  @CrossOrigin("*")  | ||||
| @RestController | ||||
| public class tokenFree_DistrictController { | ||||
| 	@Autowired | ||||
| 	private DistrictService Service; | ||||
| 
 | ||||
| @Value("${projectPath}") | ||||
| 	private String projectPath; | ||||
|   | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 	@PostMapping("/District") | ||||
| 		  public District Savedata(@RequestBody District data) { | ||||
| 		District save = Service.Savedata(data)	; | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 		System.out.println("data saved..." + save); | ||||
| 
 | ||||
|  return save; | ||||
| 	  } | ||||
| @PutMapping("/District/{id}") | ||||
| 	public  District update(@RequestBody District data,@PathVariable Integer id ) { | ||||
| 		District update = Service.update(data,id); | ||||
| 		System.out.println("data update..." + update); | ||||
| 		return update; | ||||
| 	}	  | ||||
| //	get all with pagination | ||||
| 	@GetMapping("/District/getall/page") | ||||
| 	public Page<District> getall(@RequestParam(value = "page", required = false) Integer page, | ||||
| 			@RequestParam(value = "size", required = false) Integer size) { | ||||
| 		Pageable paging = PageRequest.of(page, size); | ||||
| 		Page<District> get = Service.getAllWithPagination(paging); | ||||
| 
 | ||||
| 		return get; | ||||
| 
 | ||||
| 	}	 | ||||
| 	@GetMapping("/District") | ||||
| 	public List<District> getdetails() { | ||||
| 		 List<District> get = Service.getdetails();		 | ||||
| 		return get; | ||||
| } | ||||
| // get all without authentication  | ||||
| 
 | ||||
| 	@GetMapping("/token/District") | ||||
| 	public List<District> getallwioutsec() { | ||||
| 		 List<District> get = Service.getdetails();		 | ||||
| 		return get; | ||||
| } | ||||
| @GetMapping("/District/{id}") | ||||
| 	public  District  getdetailsbyId(@PathVariable Integer id ) { | ||||
| 		District  get = Service.getdetailsbyId(id); | ||||
| 		return get; | ||||
| 	} | ||||
| @DeleteMapping("/District/{id}") | ||||
| 	public  ResponseEntity<?> delete_by_id(@PathVariable Integer id ) { | ||||
| 	Service.delete_by_id(id); | ||||
| 			return new ResponseEntity<>(new EntityResponse("Deleted"), HttpStatus.OK); | ||||
| 	 | ||||
| 	} | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| } | ||||
| @ -0,0 +1,107 @@ | ||||
| package com.realnet.testdata.Controllers; | ||||
| import java.util.List; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | ||||
|  import org.springframework.web.bind.annotation.*; | ||||
| import org.springframework.web.multipart.MultipartFile; | ||||
| import com.fasterxml.jackson.core.JsonProcessingException; | ||||
| import org.springframework.web.bind.annotation.CrossOrigin; | ||||
| import com.fasterxml.jackson.databind.JsonMappingException; | ||||
| import com.realnet.config.EmailService; | ||||
| import com.realnet.users.entity1.AppUser; | ||||
| import com.realnet.users.service1.AppUserServiceImpl; | ||||
| import com.fasterxml.jackson.databind.ObjectMapper; | ||||
| import org.springframework.data.domain.*; | ||||
| import com.realnet.fnd.response.EntityResponse; | ||||
| import org.springframework.http.*; | ||||
| import org.springframework.beans.factory.annotation.*; | ||||
| import com.realnet.testdata.Entity.State; | ||||
| import com.realnet.testdata.Services.StateService ; | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| @RequestMapping(value = "/token/State") | ||||
|  @CrossOrigin("*")  | ||||
| @RestController | ||||
| public class tokenFree_StateController { | ||||
| 	@Autowired | ||||
| 	private StateService Service; | ||||
| 
 | ||||
| @Value("${projectPath}") | ||||
| 	private String projectPath; | ||||
|   | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 	@PostMapping("/State") | ||||
| 		  public State Savedata(@RequestBody State data) { | ||||
| 		State save = Service.Savedata(data)	; | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 		System.out.println("data saved..." + save); | ||||
| 
 | ||||
|  return save; | ||||
| 	  } | ||||
| @PutMapping("/State/{id}") | ||||
| 	public  State update(@RequestBody State data,@PathVariable Integer id ) { | ||||
| 		State update = Service.update(data,id); | ||||
| 		System.out.println("data update..." + update); | ||||
| 		return update; | ||||
| 	}	  | ||||
| //	get all with pagination | ||||
| 	@GetMapping("/State/getall/page") | ||||
| 	public Page<State> getall(@RequestParam(value = "page", required = false) Integer page, | ||||
| 			@RequestParam(value = "size", required = false) Integer size) { | ||||
| 		Pageable paging = PageRequest.of(page, size); | ||||
| 		Page<State> get = Service.getAllWithPagination(paging); | ||||
| 
 | ||||
| 		return get; | ||||
| 
 | ||||
| 	}	 | ||||
| 	@GetMapping("/State") | ||||
| 	public List<State> getdetails() { | ||||
| 		 List<State> get = Service.getdetails();		 | ||||
| 		return get; | ||||
| } | ||||
| // get all without authentication  | ||||
| 
 | ||||
| 	@GetMapping("/token/State") | ||||
| 	public List<State> getallwioutsec() { | ||||
| 		 List<State> get = Service.getdetails();		 | ||||
| 		return get; | ||||
| } | ||||
| @GetMapping("/State/{id}") | ||||
| 	public  State  getdetailsbyId(@PathVariable Integer id ) { | ||||
| 		State  get = Service.getdetailsbyId(id); | ||||
| 		return get; | ||||
| 	} | ||||
| @DeleteMapping("/State/{id}") | ||||
| 	public  ResponseEntity<?> delete_by_id(@PathVariable Integer id ) { | ||||
| 	Service.delete_by_id(id); | ||||
| 			return new ResponseEntity<>(new EntityResponse("Deleted"), HttpStatus.OK); | ||||
| 	 | ||||
| 	} | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| } | ||||
| @ -0,0 +1,33 @@ | ||||
| package com.realnet.testdata.Entity; | ||||
|  import lombok.*; | ||||
| import com.realnet.WhoColumn.Entity.Extension;  | ||||
|  import javax.persistence.*; | ||||
|  import java.time.LocalDateTime; | ||||
|  import java.util.*; | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|  @Entity  | ||||
|  @Data | ||||
|  public class    Country extends Extension {  | ||||
|  /** | ||||
| 	 *  | ||||
| 	 */ | ||||
| 	private static final long serialVersionUID = 1L; | ||||
| 
 | ||||
|  @Id | ||||
|  @GeneratedValue(strategy = GenerationType.IDENTITY) | ||||
|  private Integer id; | ||||
| 
 | ||||
| private String  name; | ||||
| 
 | ||||
| @Column(length = 2000) | ||||
| private String description; | ||||
| 
 | ||||
| private Boolean active; | ||||
| 
 | ||||
| 
 | ||||
| } | ||||
| @ -0,0 +1,15 @@ | ||||
| package com.realnet.testdata.Entity; | ||||
|  import lombok.*; | ||||
|  import javax.persistence.*; | ||||
|  import java.time.LocalDateTime; | ||||
|  import java.util.*; | ||||
| 
 | ||||
|  @Data | ||||
|  public class    Country_ListFilter1 {  | ||||
| 
 | ||||
|  private Integer id; | ||||
| 
 | ||||
| 
 | ||||
|  private String name; | ||||
|  private String description; | ||||
| } | ||||
| @ -0,0 +1,37 @@ | ||||
| package com.realnet.testdata.Entity; | ||||
|  import lombok.*; | ||||
| import com.realnet.WhoColumn.Entity.Extension;  | ||||
|  import javax.persistence.*; | ||||
|  import java.time.LocalDateTime; | ||||
|  import java.util.*; | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|  @Entity  | ||||
|  @Data | ||||
|  public class    District extends Extension {  | ||||
|  /** | ||||
| 	 *  | ||||
| 	 */ | ||||
| 	private static final long serialVersionUID = 1L; | ||||
| 
 | ||||
|  @Id | ||||
|  @GeneratedValue(strategy = GenerationType.IDENTITY) | ||||
|  private Integer id; | ||||
| 
 | ||||
| private String  district_name; | ||||
| 
 | ||||
| @Column(length = 2000) | ||||
| private String description; | ||||
| 
 | ||||
| private Boolean active; | ||||
| 
 | ||||
| private String  state_name; | ||||
| 
 | ||||
| 
 | ||||
| } | ||||
| @ -0,0 +1,37 @@ | ||||
| package com.realnet.testdata.Entity; | ||||
|  import lombok.*; | ||||
| import com.realnet.WhoColumn.Entity.Extension;  | ||||
|  import javax.persistence.*; | ||||
|  import java.time.LocalDateTime; | ||||
|  import java.util.*; | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|  @Entity  | ||||
|  @Data | ||||
|  public class    State extends Extension {  | ||||
|  /** | ||||
| 	 *  | ||||
| 	 */ | ||||
| 	private static final long serialVersionUID = 1L; | ||||
| 
 | ||||
|  @Id | ||||
|  @GeneratedValue(strategy = GenerationType.IDENTITY) | ||||
|  private Integer id; | ||||
| 
 | ||||
| private String  state_name; | ||||
| 
 | ||||
| @Column(length = 2000) | ||||
| private String description; | ||||
| 
 | ||||
| private Boolean active; | ||||
| 
 | ||||
| private String  country_name; | ||||
| 
 | ||||
| 
 | ||||
| } | ||||
| @ -0,0 +1,30 @@ | ||||
| package com.realnet.testdata.Repository; | ||||
| 
 | ||||
| 
 | ||||
| import org.springframework.data.domain.Page; | ||||
| import org.springframework.data.domain.Pageable; | ||||
| import org.springframework.data.jpa.repository.JpaRepository; | ||||
| import org.springframework.data.jpa.repository.Query; | ||||
| 
 | ||||
| import org.springframework.stereotype.Repository;  | ||||
| import java.util.*; | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|   | ||||
| 
 | ||||
| import com.realnet.testdata.Entity.Country; | ||||
| 
 | ||||
| @Repository | ||||
| public interface  CountryRepository  extends  JpaRepository<Country, Integer>  {  | ||||
| 
 | ||||
| @Query(value = "select * from country where  created_by=?1", nativeQuery = true) | ||||
| 	List<Country> findAll(Long creayedBy); | ||||
| 
 | ||||
| @Query(value = "select * from country where  created_by=?1", nativeQuery = true) | ||||
| 	Page<Country> findAll( Long creayedBy,Pageable page); | ||||
| } | ||||
| @ -0,0 +1,32 @@ | ||||
| package com.realnet.testdata.Repository; | ||||
| 
 | ||||
| 
 | ||||
| import org.springframework.data.domain.Page; | ||||
| import org.springframework.data.domain.Pageable; | ||||
| import org.springframework.data.jpa.repository.JpaRepository; | ||||
| import org.springframework.data.jpa.repository.Query; | ||||
| 
 | ||||
| import org.springframework.stereotype.Repository;  | ||||
| import java.util.*; | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|   | ||||
| 
 | ||||
| import com.realnet.testdata.Entity.District; | ||||
| 
 | ||||
| @Repository | ||||
| public interface  DistrictRepository  extends  JpaRepository<District, Integer>  {  | ||||
| 
 | ||||
| @Query(value = "select * from district where  created_by=?1", nativeQuery = true) | ||||
| 	List<District> findAll(Long creayedBy); | ||||
| 
 | ||||
| @Query(value = "select * from district where  created_by=?1", nativeQuery = true) | ||||
| 	Page<District> findAll( Long creayedBy,Pageable page); | ||||
| } | ||||
| @ -0,0 +1,32 @@ | ||||
| package com.realnet.testdata.Repository; | ||||
| 
 | ||||
| 
 | ||||
| import org.springframework.data.domain.Page; | ||||
| import org.springframework.data.domain.Pageable; | ||||
| import org.springframework.data.jpa.repository.JpaRepository; | ||||
| import org.springframework.data.jpa.repository.Query; | ||||
| 
 | ||||
| import org.springframework.stereotype.Repository;  | ||||
| import java.util.*; | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|   | ||||
| 
 | ||||
| import com.realnet.testdata.Entity.State; | ||||
| 
 | ||||
| @Repository | ||||
| public interface  StateRepository  extends  JpaRepository<State, Integer>  {  | ||||
| 
 | ||||
| @Query(value = "select * from state where  created_by=?1", nativeQuery = true) | ||||
| 	List<State> findAll(Long creayedBy); | ||||
| 
 | ||||
| @Query(value = "select * from state where  created_by=?1", nativeQuery = true) | ||||
| 	Page<State> findAll( Long creayedBy,Pageable page); | ||||
| } | ||||
| @ -0,0 +1,93 @@ | ||||
| package com.realnet.testdata.Services; | ||||
| import com.realnet.testdata.Repository.CountryRepository; | ||||
| import com.realnet.testdata.Entity.Country | ||||
| ;import java.util.*; | ||||
| 
 | ||||
| import org.springframework.beans.factory.annotation.Autowired; | ||||
| import com.realnet.SequenceGenerator.Service.SequenceService; | ||||
| import org.springframework.data.domain.Page; | ||||
| import com.realnet.realm.Entity.Realm; | ||||
| import com.realnet.realm.Services.RealmService; | ||||
| import org.springframework.data.domain.Pageable; | ||||
| import org.springframework.http.*; | ||||
| import com.realnet.users.service1.AppUserServiceImpl; | ||||
| import com.realnet.users.entity1.AppUser; | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 	import org.springframework.stereotype.Service; | ||||
| 
 | ||||
| @Service | ||||
|  public class CountryService { | ||||
| @Autowired | ||||
| private CountryRepository Repository; | ||||
| 	@Autowired | ||||
| 	private AppUserServiceImpl userService;  | ||||
| @Autowired | ||||
| 	private RealmService realmService; | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| public Country Savedata(Country data) { | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 	data.setUpdatedBy(getUser().getUserId()); | ||||
| 		data.setCreatedBy(getUser().getUserId()); | ||||
| 		data.setAccountId(getUser().getAccount().getAccount_id()); | ||||
| Country save = Repository.save(data); | ||||
| 				return save;	 | ||||
| 			} | ||||
| 
 | ||||
| 
 | ||||
| //	get all with pagination | ||||
| 	public Page<Country> getAllWithPagination(Pageable page) { | ||||
| 		return Repository.findAll( getUser().getUserId(),page); | ||||
| 	}			 | ||||
| public List<Country> getdetails() {   | ||||
| 		List<Realm> realm = realmService.findByUserId(getUser().getUserId()); | ||||
| List<Country> all = Repository.findAll(getUser().getUserId()); | ||||
| 		 | ||||
| 		return all ;		} | ||||
| 
 | ||||
| 
 | ||||
| public Country getdetailsbyId(Integer id) { | ||||
| 	return Repository.findById(id).get(); | ||||
| 			} | ||||
| 
 | ||||
| 
 | ||||
| 	public void delete_by_id(Integer id) { | ||||
|  Repository.deleteById(id); | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| public Country update(Country data,Integer id) { | ||||
| 	Country old = Repository.findById(id).get(); | ||||
| old.setName(data.getName()); | ||||
| 
 | ||||
| old.setDescription(data.getDescription()); | ||||
| 
 | ||||
| old.setActive (data.getActive()); | ||||
| 
 | ||||
| final Country test = Repository.save(old); | ||||
| 		data.setUpdatedBy(getUser().getUserId()); | ||||
|   return test;}  | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|  public AppUser getUser() { | ||||
| 		AppUser user = userService.getLoggedInUser(); | ||||
| 		return user; | ||||
| 
 | ||||
| 	}} | ||||
| @ -0,0 +1,53 @@ | ||||
| package com.realnet.testdata.Services; | ||||
| import java.util.*; | ||||
| import com.realnet.testdata.Repository.CountryRepository; | ||||
| import com.realnet.testdata.Entity.Country; | ||||
| 
 | ||||
| import com.realnet.testdata.Entity.Country_ListFilter1; | ||||
| import java.util.List; | ||||
| 
 | ||||
| import org.springframework.beans.factory.annotation.Autowired; | ||||
| 	import org.springframework.stereotype.Service; | ||||
| 
 | ||||
| @Service | ||||
|  public class Country_ListFilter1Service { | ||||
| @Autowired | ||||
| private CountryRepository Repository; | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|  public   List<Country_ListFilter1>   getlistbuilder() { | ||||
| 	List<Country> list= Repository.findAll(); | ||||
| 		ArrayList<Country_ListFilter1> l = new ArrayList<>(); | ||||
| 		for (Country data : list) { | ||||
| Boolean isActive = data.getActive(); | ||||
| 
 | ||||
| 				if (Boolean.TRUE.equals(isActive)) {{	 | ||||
| Country_ListFilter1 dummy = new Country_ListFilter1(); | ||||
| 			dummy.setId(data.getId()); | ||||
|   dummy.setName(data.getName()); | ||||
|   dummy.setDescription(data.getDescription()); | ||||
| 	l.add(dummy); | ||||
| }}  | ||||
| } 		 | ||||
| return l;} | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|  public   List<Country_ListFilter1>   getlistbuilderparam( ) { | ||||
| 	List<Country> list= Repository.findAll(); | ||||
| 		ArrayList<Country_ListFilter1> l = new ArrayList<>(); | ||||
| 		for (Country data : list) { | ||||
| Boolean isActive = data.getActive(); | ||||
| 
 | ||||
| 				if (Boolean.TRUE.equals(isActive)) {{	 | ||||
| Country_ListFilter1 dummy = new Country_ListFilter1(); | ||||
| 			dummy.setId(data.getId()); | ||||
|   dummy.setName(data.getName()); | ||||
|   dummy.setDescription(data.getDescription()); | ||||
| 	l.add(dummy); | ||||
| }}  | ||||
| } 		 | ||||
| return l;} | ||||
| } | ||||
| @ -0,0 +1,103 @@ | ||||
| package com.realnet.testdata.Services; | ||||
| import com.realnet.testdata.Repository.DistrictRepository; | ||||
| import com.realnet.testdata.Entity.District | ||||
| ;import java.util.*; | ||||
| 
 | ||||
| import org.springframework.beans.factory.annotation.Autowired; | ||||
| import com.realnet.SequenceGenerator.Service.SequenceService; | ||||
| import org.springframework.data.domain.Page; | ||||
| import com.realnet.realm.Entity.Realm; | ||||
| import com.realnet.realm.Services.RealmService; | ||||
| import org.springframework.data.domain.Pageable; | ||||
| import org.springframework.http.*; | ||||
| import com.realnet.users.service1.AppUserServiceImpl; | ||||
| import com.realnet.users.entity1.AppUser; | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 	import org.springframework.stereotype.Service; | ||||
| 
 | ||||
| @Service | ||||
|  public class DistrictService { | ||||
| @Autowired | ||||
| private DistrictRepository Repository; | ||||
| 	@Autowired | ||||
| 	private AppUserServiceImpl userService;  | ||||
| @Autowired | ||||
| 	private RealmService realmService; | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| public District Savedata(District data) { | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 	data.setUpdatedBy(getUser().getUserId()); | ||||
| 		data.setCreatedBy(getUser().getUserId()); | ||||
| 		data.setAccountId(getUser().getAccount().getAccount_id()); | ||||
| District save = Repository.save(data); | ||||
| 				return save;	 | ||||
| 			} | ||||
| 
 | ||||
| 
 | ||||
| //	get all with pagination | ||||
| 	public Page<District> getAllWithPagination(Pageable page) { | ||||
| 		return Repository.findAll( getUser().getUserId(),page); | ||||
| 	}			 | ||||
| public List<District> getdetails() {   | ||||
| 		List<Realm> realm = realmService.findByUserId(getUser().getUserId()); | ||||
| List<District> all = Repository.findAll(getUser().getUserId()); | ||||
| 		 | ||||
| 		return all ;		} | ||||
| 
 | ||||
| 
 | ||||
| public District getdetailsbyId(Integer id) { | ||||
| 	return Repository.findById(id).get(); | ||||
| 			} | ||||
| 
 | ||||
| 
 | ||||
| 	public void delete_by_id(Integer id) { | ||||
|  Repository.deleteById(id); | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| public District update(District data,Integer id) { | ||||
| 	District old = Repository.findById(id).get(); | ||||
| old.setDistrict_name(data.getDistrict_name()); | ||||
| 
 | ||||
| old.setDescription(data.getDescription()); | ||||
| 
 | ||||
| old.setActive (data.getActive()); | ||||
| 
 | ||||
| old.setState_name(data.getState_name()); | ||||
| 
 | ||||
| final District test = Repository.save(old); | ||||
| 		data.setUpdatedBy(getUser().getUserId()); | ||||
|   return test;}  | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|  public AppUser getUser() { | ||||
| 		AppUser user = userService.getLoggedInUser(); | ||||
| 		return user; | ||||
| 
 | ||||
| 	}} | ||||
| @ -0,0 +1,103 @@ | ||||
| package com.realnet.testdata.Services; | ||||
| import com.realnet.testdata.Repository.StateRepository; | ||||
| import com.realnet.testdata.Entity.State | ||||
| ;import java.util.*; | ||||
| 
 | ||||
| import org.springframework.beans.factory.annotation.Autowired; | ||||
| import com.realnet.SequenceGenerator.Service.SequenceService; | ||||
| import org.springframework.data.domain.Page; | ||||
| import com.realnet.realm.Entity.Realm; | ||||
| import com.realnet.realm.Services.RealmService; | ||||
| import org.springframework.data.domain.Pageable; | ||||
| import org.springframework.http.*; | ||||
| import com.realnet.users.service1.AppUserServiceImpl; | ||||
| import com.realnet.users.entity1.AppUser; | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 	import org.springframework.stereotype.Service; | ||||
| 
 | ||||
| @Service | ||||
|  public class StateService { | ||||
| @Autowired | ||||
| private StateRepository Repository; | ||||
| 	@Autowired | ||||
| 	private AppUserServiceImpl userService;  | ||||
| @Autowired | ||||
| 	private RealmService realmService; | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| public State Savedata(State data) { | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 	data.setUpdatedBy(getUser().getUserId()); | ||||
| 		data.setCreatedBy(getUser().getUserId()); | ||||
| 		data.setAccountId(getUser().getAccount().getAccount_id()); | ||||
| State save = Repository.save(data); | ||||
| 				return save;	 | ||||
| 			} | ||||
| 
 | ||||
| 
 | ||||
| //	get all with pagination | ||||
| 	public Page<State> getAllWithPagination(Pageable page) { | ||||
| 		return Repository.findAll( getUser().getUserId(),page); | ||||
| 	}			 | ||||
| public List<State> getdetails() {   | ||||
| 		List<Realm> realm = realmService.findByUserId(getUser().getUserId()); | ||||
| List<State> all = Repository.findAll(getUser().getUserId()); | ||||
| 		 | ||||
| 		return all ;		} | ||||
| 
 | ||||
| 
 | ||||
| public State getdetailsbyId(Integer id) { | ||||
| 	return Repository.findById(id).get(); | ||||
| 			} | ||||
| 
 | ||||
| 
 | ||||
| 	public void delete_by_id(Integer id) { | ||||
|  Repository.deleteById(id); | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| public State update(State data,Integer id) { | ||||
| 	State old = Repository.findById(id).get(); | ||||
| old.setState_name(data.getState_name()); | ||||
| 
 | ||||
| old.setDescription(data.getDescription()); | ||||
| 
 | ||||
| old.setActive (data.getActive()); | ||||
| 
 | ||||
| old.setCountry_name(data.getCountry_name()); | ||||
| 
 | ||||
| final State test = Repository.save(old); | ||||
| 		data.setUpdatedBy(getUser().getUserId()); | ||||
|   return test;}  | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|  public AppUser getUser() { | ||||
| 		AppUser user = userService.getLoggedInUser(); | ||||
| 		return user; | ||||
| 
 | ||||
| 	}} | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user