updateServiceVariation function

Future<ServiceVariation> updateServiceVariation(
  1. int? variationsId,
  2. String variationName,
  3. String vendor,
  4. String control,
)

Implementation

Future<ServiceVariation> updateServiceVariation(int? variationsId,
    String variationName, String vendor, String control) async {
  HttpOverrides.global = new MyHttpOverrides();
  final response = await http.put(
    Uri.parse(
        'https://192.168.1.106:45455/api/ServiceVariationsModels/$variationsId'),
    headers: <String, String>{
      'Content-Type': 'application/json; charset=UTF-8',
    },
    body: jsonEncode(<String, String>{
      'variationsId': variationsId.toString(),
      'variationName': variationName,
      'vendor': vendor,
      'control': control
    }),
  );

  if (response.statusCode == 201) {
    // If the server did return a 201 CREATED response,
    // then parse the JSON.
    return ServiceVariation.fromJson(jsonDecode(response.body));
  } else {
    // If the server did not return a 201 CREATED response,
    // then throw an exception.
    throw Exception('Failed to create Service Variation.');
  }
}