From 6059c97b9a7632103a7bae5ed8bd838c3274e9dc Mon Sep 17 00:00:00 2001 From: niloysikdar Date: Sun, 2 May 2021 03:21:34 +0530 Subject: [PATCH] Added uploadOxygen Function --- .../{oxygenpost.dart => oxygenpostmodel.dart} | 0 lib/services/database.dart | 14 ++++++++++++++ 2 files changed, 14 insertions(+) rename lib/models/{oxygenpost.dart => oxygenpostmodel.dart} (100%) diff --git a/lib/models/oxygenpost.dart b/lib/models/oxygenpostmodel.dart similarity index 100% rename from lib/models/oxygenpost.dart rename to lib/models/oxygenpostmodel.dart diff --git a/lib/services/database.dart b/lib/services/database.dart index bceb548..7a6b3b7 100644 --- a/lib/services/database.dart +++ b/lib/services/database.dart @@ -1,5 +1,6 @@ import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:plaso_connect/models/donormodel.dart'; +import 'package:plaso_connect/models/oxygenpostmodel.dart'; class DatabaseMethod { final FirebaseFirestore db = FirebaseFirestore.instance; @@ -20,4 +21,17 @@ class DatabaseMethod { .where("pin", isEqualTo: pin) .snapshots(); } + + Future uploadOxygen(OxygenPostModel oxygenPostModel) async { + var userMap = oxygenPostModel.toMap(); + try { + await db + .collection("oxygenPosts") + .doc(oxygenPostModel.title) + .set(userMap); + print("Done"); + } catch (e) { + print(e.toString()); + } + } }