import 'package:dio/dio.dart';
import '../../../../data/network/base_network_service.dart';
import '../../../../data/network/network_api_service.dart';
import '../../../../resources/api_constants.dart';

class TestmRepoScreen {
  final String baseUrl = ApiConstants.baseUrl;
  final BaseNetworkService _helper = NetworkApiService();

  Future<dynamic> getEntities() async {
    try {
      final response =
          await _helper.getGetApiResponse('$baseUrl/Testm/Testm');
      return response;
    } catch (e) {
      throw Exception('Failed to get all entities: $e');
    }
  }

  Future<dynamic> getAllWithPagination(int page, int size) async {
    try {
      final response = await _helper.getGetApiResponse(
          '$baseUrl/Testm/Testm/getall/page?page=$page&size=$size');
      return response;
    } catch (e) {
      throw Exception('Failed to get all without pagination: $e');
    }
  }

  Future<dynamic> createEntity(Map<String, dynamic> entity) async {
    try {
      print("in post api$entity");
      final response = await _helper.getPostApiResponse(
          '$baseUrl/Testm/Testm', entity);

      print(entity);

      return response;
    } catch (e) {
      throw Exception('Failed to create entity: $e');
    }
  }

  Future<void> updateEntity(int entityId, Map<String, dynamic> entity) async {
    try {
      await _helper.getPutApiResponse(
          '$baseUrl/Testm/Testm/$entityId', entity);
      print(entity);
    } catch (e) {
      throw Exception('Failed to update entity: $e');
    }
  }

  Future<void> deleteEntity(int entityId) async {
    try {
      await _helper
          .getDeleteApiResponse('$baseUrl/Testm/Testm/$entityId');
    } catch (e) {
      throw Exception('Failed to delete entity: $e');
    }
  }






 Future<dynamic> getselecdya() async {
    try {
      String apiUrl = "$baseUrl/Testm_ListFilter1/Testm_ListFilter1";
      final response = await _helper.getGetApiResponse(apiUrl);
      return response;
    } catch (e) {
      throw Exception('Failed to Get: $e');
    }
  }

 Future<dynamic> getselectdyamul() async {
    try {
      String apiUrl = "$baseUrl/Testm_ListFilter1/Testm_ListFilter1";
      final response = await _helper.getGetApiResponse(apiUrl);
      return response;
    } catch (e) {
      throw Exception('Failed to Get: $e');
    }
  }

 Future<dynamic> getselectauto() async {
    try {
      String apiUrl = "$baseUrl/Testm_ListFilter1/Testm_ListFilter1";
      final response = await _helper.getGetApiResponse(apiUrl);
      return response;
    } catch (e) {
      throw Exception('Failed to Get: $e');
    }
  }

 Future<dynamic> getselectautomul() async {
    try {
      String apiUrl = "$baseUrl/Testm_ListFilter1/Testm_ListFilter1";
      final response = await _helper.getGetApiResponse(apiUrl);
      return response;
    } catch (e) {
      throw Exception('Failed to Get: $e');
    }
  }













 Future<dynamic> getdatagggGrid() async {
    try {
      String apiUrl = "$baseUrl/Testm";
      final response = await _helper.getGetApiResponse(apiUrl);
      return response;
    } catch (e) {
      throw Exception('Failed to Upload dataggg: $e');
    }
  }

}
