updateService function
Future<Service>
updateService(
- int? serviceId,
- String serviceName,
- String serviceDescription,
- String ssu,
- String servicePrice,
- int stock,
- String serviceSpecialPrice,
- String specialPriceStart,
- String specialPriceEnd,
- String taxType,
- String isPublished,
- String vendor,
)
Implementation
Future<Service> updateService(
int? serviceId,
String serviceName,
String serviceDescription,
String ssu,
String servicePrice,
int stock,
String serviceSpecialPrice,
String specialPriceStart,
String specialPriceEnd,
String taxType,
String isPublished,
String vendor) async {
HttpOverrides.global = new MyHttpOverrides();
final response = await http.put(
Uri.parse(
'https://192.168.1.106:45455/api/ServiceInformationModels/$serviceId'),
headers: <String, String>{
'Content-Type': 'application/json; charset=UTF-8',
},
body: jsonEncode(<String, String>{
'serviceId': serviceId.toString(),
'serviceName': serviceName,
'serviceDescription': serviceDescription,
'ssu': ssu,
'servicePrice': servicePrice,
'stock': stock.toString(),
'serviceSpecialPrice': serviceSpecialPrice,
'specialPriceStart': specialPriceStart,
'specialPriceEnd': specialPriceEnd,
'taxType': taxType,
'isPublished': isPublished,
'vendor': vendor
}),
);
if (response.statusCode == 200) {
// If the server did return a 200 CREATED response,
// then parse the JSON.
return Service.fromJson(jsonDecode(response.body));
} else {
// If the server did not return a 200 CREATED response,
// then throw an exception.
throw Exception('Failed to update service.');
}
}