コード例 #1
0
        /// <summary>
        ///  Write to Firebase when reading from SQLIte.
        /// </summary>
        /// <param name="state"></param>
        /// <param name="iD"></param>
        public async void AddNewTreatmentPlanState(int treatmentPlanID, string customerID, TreatmentPlaneState state, string creationDate, string treatmentPlanCompleteDate)
        {
            ConnectToFirebase();

            int realState = 0;

            if (state.ToString() == "Created")
            {
                realState = 0;
            }
            if (state.ToString() == "Accepted")
            {
                realState = 1;
            }
            if (state.ToString() == "Finish")
            {
                realState = 2;
            }

            string userName   = DAO.GetUserID();
            String myUsername = userName;

            myUsername = myUsername.Replace(".", "-");
            String node = myUsername + "TreatmentPlans" + "/";
            var    treatmentPlanData = new TreatmentPlanData
            {
                treatmentPlanID           = treatmentPlanID,
                customerID                = customerID,
                state                     = realState,
                creationDate              = creationDate,
                treatmentPlanCompleteDate = treatmentPlanCompleteDate
            };

            await firebase.Child(node).PostAsync <TreatmentPlanData>(treatmentPlanData);
        }
コード例 #2
0
        /// <summary>
        /// Update Treatmentplan table in Firebase if state changes.
        /// </summary>
        /// <param name="state"></param>
        /// <param name="iD"></param>
        public async void UpdateTreatmentPlanState(TreatmentPlaneState state, int iD)
        {
            ConnectToFirebase();

            int realState = 0;

            if (state.ToString() == "Created")
            {
                realState = 0;
            }
            if (state.ToString() == "Accepted")
            {
                realState = 1;
            }
            if (state.ToString() == "Finish")
            {
                realState = 2;
            }


            int    treatmentPlanID           = 0;
            string customerID                = "";
            string creationDate              = "";
            string treatmentPlanCompleteDate = "";

            string userName   = DAO.GetUserID();
            String myUsername = userName;

            myUsername = myUsername.Replace(".", "-");
            String node = myUsername + "TreatmentPlans" + "/";
            var    treatmentPlanData = new TreatmentPlanData
            {
                treatmentPlanID = iD,
            };

            var results = await firebase.Child(node).OnceAsync <TreatmentPlanData>();

            foreach (var details in results)
            {
                if (iD == details.Object.treatmentPlanID)
                {
                    treatmentPlanID           = details.Object.treatmentPlanID;
                    customerID                = details.Object.customerID;
                    creationDate              = details.Object.creationDate;
                    treatmentPlanCompleteDate = details.Object.treatmentPlanCompleteDate;
                    await firebase.Child(node).Child(details.Key).DeleteAsync();

                    AddNewTreatmentPlan(treatmentPlanID, customerID, realState, creationDate, treatmentPlanCompleteDate);
                    break;
                }
            }
        }