updateOrders function

Future<Orders> updateOrders(
  1. int? orderId,
  2. String orderStatus,
  3. String vendor,
  4. String customer,
  5. String startDate,
  6. String endDate,
  7. String orderTotal,
)

Implementation

Future<Orders> updateOrders(
    int? orderId,
    String orderStatus,
    String vendor,
    String customer,
    String startDate,
    String endDate,
    String orderTotal) async {
  HttpOverrides.global = new MyHttpOverrides();
  final response = await http.put(
    Uri.parse('https://192.168.1.106:45455/api/OrdersModels/$orderId'),
    headers: <String, String>{
      'Content-Type': 'application/json; charset=UTF-8',
    },
    body: jsonEncode(<String, String>{
      'orderId': orderId.toString(),
      'orderStatus': orderStatus,
      'vendor': vendor,
      'customer': customer,
      'startDate': startDate,
      'endDate': endDate,
      'orderTotal': orderTotal
    }),
  );

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