/// <summary> /// Update the Treatment table by row id /// </summary> /// <param name="treatment"></param> public async void UpdateTreatment(Treatment treatment) { ConnectToFirebase(); string userName = DAO.GetUserID(); String myUsername = userName; myUsername = myUsername.Replace(".", "-"); String node = myUsername + "Treatments" + "/"; TreatmentData treatmentData = new TreatmentData { iD = treatment.ID, name = treatment.Name, price = treatment.Price }; var results = await firebase.Child(node).OnceAsync <TreatmentData>(); foreach (var details in results) { if (Convert.ToInt32(details.Object.iD) == treatment.ID) { //Delete the old row by key Id await firebase.Child(node).Child(details.Key).DeleteAsync(); //Create a new row with the updated values await firebase.Child(node).PostAsync <TreatmentData>(treatmentData); break; } } }
/// <summary> /// Add a new treatment to Firebae /// </summary> /// <param name="treatmentName"></param> /// <param name="price"></param> public async void AddNewTreatment(Treatment treatment) { ConnectToFirebase(); string userName = DAO.GetUserID(); String myUsername = userName; myUsername = myUsername.Replace(".", "-"); String node = myUsername + "Treatments" + "/"; TreatmentData treatmentData = new TreatmentData { iD = treatment.ID, name = treatment.Name, price = treatment.Price }; await firebase.Child(node).PostAsync <TreatmentData>(treatmentData); }