createOrders function

Future<Orders> createOrders(
  1. String orderStatus,
  2. String vendor,
  3. String customer,
  4. String startDate,
  5. String endDate,
  6. String orderTotal,
)

Implementation

Future<Orders> createOrders(
    //int? orderId,
    String orderStatus,
    String vendor,
    String customer,
    String startDate,
    String endDate,
    String orderTotal) async {
  HttpOverrides.global = new MyHttpOverrides();
  final response = await http.post(
    Uri.parse('https://172.30.1.10:45455/api/OrdersModels'),
    //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>{
      '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.');
  }
}