public void TakeTeacherAttendance(IList <string> teacherIds, DateTime date)
        {
            string d = date.ToString("MM/dd/yyyy");

            foreach (string teacherId in Teachers.Keys)
            {
                DocumentReference dr = db.Collection("teachers").Document(teacherId);

                DocumentSnapshot snapshot = Teachers[teacherId];

                try
                {
                    snapshot.GetValue <string[]>("attended");
                    if (teacherIds.Contains(teacherId))
                    {
                        dr.UpdateAsync("attended", FieldValue.ArrayUnion(d)).Wait();
                    }
                    else
                    {
                        dr.UpdateAsync("attended", FieldValue.ArrayRemove(d)).Wait();
                    }
                }
                catch
                {
                    if (teacherIds.Contains(teacherId))
                    {
                        Dictionary <string, object> update = new Dictionary <string, object>
                        {
                            { "attended", new string[] { d } }
                        };
                        dr.SetAsync(update, SetOptions.MergeAll).Wait();
                    }
                }
            }
        }
예제 #2
0
    public async void UpdateSelected(string deckId)
    {
        foreach (Transform child in transform)
        {
            child.gameObject.GetComponent <DeckScript>().selectButton.SetActive(true);
        }
        foreach (Transform child in transform)
        {
            if (child.gameObject.GetComponent <DeckScript>().deckId == deckId)
            {
                child.gameObject.GetComponent <DeckScript>().selectButton.SetActive(false);
            }
        }
        DocumentReference           deckRef = MainManager.Instance.firebaseManager.firestore.Collection("users").Document(MainManager.Instance.currentUserId).Collection("decks").Document(previousDeck);
        Dictionary <string, object> updates = new Dictionary <string, object>
        {
            { "selected", false }
        };
        await deckRef.UpdateAsync(updates);

        deckRef = MainManager.Instance.firebaseManager.firestore.Collection("users").Document(MainManager.Instance.currentUserId).Collection("decks").Document(deckId);
        updates = new Dictionary <string, object>
        {
            { "selected", true }
        };
        await deckRef.UpdateAsync(updates);

        previousDeck = deckId;
    }
예제 #3
0
파일: Firestore.cs 프로젝트: HHIED/CAD
        /// <summary>
        /// Approves a section. Returns true if the section has been approved by everyone.
        /// </summary>
        /// <param name="username">Username approving</param>
        /// <param name="sectionId">Section to approve</param>
        /// <returns>Whether section has been approved by all or not</returns>
        public async Task <Boolean> ApproveSection(string username, string sectionId)
        {
            DocumentReference   docRef   = db.Collection("sections").Document(sectionId);
            CollectionReference userRef  = db.Collection("users");
            DocumentSnapshot    snapshot = await docRef.GetSnapshotAsync();

            if (snapshot.Exists)
            {
                Section section = snapshot.ConvertTo <Section>();
                if (!section.ApprovedBy.Contains(username))
                {
                    section.ApprovedBy.Add(username);
                    await docRef.UpdateAsync("ApprovedBy", FieldValue.ArrayUnion(username));
                }
                QuerySnapshot userSnapshots = await userRef.GetSnapshotAsync();

                if (userSnapshots.Count <= section.ApprovedBy.Count())
                {
                    await docRef.UpdateAsync("ApprovedAt", Timestamp.GetCurrentTimestamp());

                    return(true);
                }
            }
            return(false);
        }
예제 #4
0
        private static async Task UpdateDocumentArray(string project)
        {
            FirestoreDb db = FirestoreDb.Create(project);
            // [START fs_update_document_array]
            DocumentReference washingtonRef = db.Collection("cities").Document("DC");

            // Atomically add a new region to the "regions" array field.
            await washingtonRef.UpdateAsync("Regions", FieldValue.ArrayUnion("greater_virginia"));

            // Atomically remove a region from the "regions" array field.
            await washingtonRef.UpdateAsync("Regions", FieldValue.ArrayRemove("east_coast"));

            // [END fs_update_document_array]
            Console.WriteLine("Updated the Regions array of the DC document in the cities collection.");
        }
        public async Task <ActionResult> Edit(string id, ClinicSettings settings)
        {
            List <SelectListItem> whofirst = new List <SelectListItem>()
            {
                new SelectListItem {
                    Text = "Chemist", Value = "Chemist"
                },
                new SelectListItem {
                    Text = "Cashier", Value = "Cashier"
                },
            };

            ViewBag.WHOFIRSTS = whofirst;
            try
            {
                if (ModelState.IsValid)
                {
                    string Path = AppDomain.CurrentDomain.BaseDirectory + @"greenpaperdev-firebase-adminsdk-8k2y5-fb46e63414.json";
                    Environment.SetEnvironmentVariable("GOOGLE_APPLICATION_CREDENTIALS", Path);
                    FirestoreDb db = FirestoreDb.Create("greenpaperdev");

                    DocumentReference docRef  = db.Collection("clinics").Document(GlobalSessionVariables.ClinicDocumentAutoId).Collection("settings").Document(id);
                    DocumentSnapshot  docSnap = await docRef.GetSnapshotAsync();



                    Dictionary <string, object> data1 = new Dictionary <string, object>
                    {
                        { "bill_sms", settings.bill_sms },
                        { "reminder_sms", settings.reminder_sms },
                        { "fee1", settings.fee1 },
                        { "fee2", settings.fee2 },
                        { "fee3", settings.fee3 },
                        { "inventoryon", settings.inventoryon },
                        { "days1", settings.days1 },
                        { "days2", settings.days2 },
                        { "days3", settings.days3 },
                        { "whofirst", settings.whofirst },
                        { "consultationfee", settings.consultationfee }
                    };


                    if (docSnap.Exists)
                    {
                        await docRef.UpdateAsync(data1);
                    }

                    return(RedirectToAction("Index"));
                }
                else
                {
                    return(View(settings));
                }
                // TODO: Add update logic here
            }
            catch
            {
                return(View(settings));
            }
        }
예제 #6
0
        public async Task <WriteResult> RemoveProductToCart(string pProductId, string pUserUId)
        {
            FirestoreDb db   = CreateInstanceDB();
            FirebaseApp wApp = CreateFirebaseApp();

            //GetData
            DocumentReference wDocRef  = db.Collection("user").Document(pUserUId);
            DocumentSnapshot  snapshot = await wDocRef.GetSnapshotAsync();

            WriteResult wWResult = null;

            Dictionary <string, object>[] wCartArray = snapshot.ContainsField("carrello") ? snapshot.GetValue <Dictionary <string, object>[]>("carrello") : null;
            if (wCartArray != null)
            {
                foreach (Dictionary <string, object> wCartDBColl in wCartArray)
                {
                    if (wCartDBColl["uidProdotto"].ToString() == pProductId)
                    {
                        wWResult = await wDocRef.UpdateAsync("carrello", FieldValue.ArrayRemove(wCartDBColl));
                    }
                }
            }
            //End get Data

            return(wWResult);
        }
예제 #7
0
        private async void UpdateDoc()
        {
            FirestoreDb db       = FirestoreDb.Create("cupofsoju-a47b2");
            string      updateid = null;
            // [START fs_delete_doc]
            CollectionReference usersRef = db.Collection("Store");
            QuerySnapshot       snapshot = await usersRef.GetSnapshotAsync();

            foreach (DocumentSnapshot document in snapshot.Documents)
            {
                Dictionary <string, object> documentDictionary = document.ToDictionary();
                if (documentDictionary["name"].ToString() == u_name)
                {
                    updateid = document.Id;
                }
            }
            if (updateid != null)
            {
                DocumentReference cityRef = db.Collection("Store").Document(updateid);

                // Update age and favorite color
                Dictionary <string, object> updates = new Dictionary <string, object>
                {
                    { "permission_state", 1 },
                };

                // Asynchronously update the document
                await cityRef.UpdateAsync(updates);
            }
            MessageBox.Show("수정 완료");
            StoreParse();
        }
예제 #8
0
    // See b/174676322 for why this test is added.
    public IEnumerator TestMultipleDeletesInOneUpdate() {
      DocumentReference doc = TestDocument();
      var setTask = doc.SetAsync(new Dictionary<string, object> {
        { "key1", "value1" },
        { "key2", "value2" },
        { "key3", "value3" },
        { "key4", "value4" },
        { "key5", "value5" },
      });
      yield return AwaitSuccess(setTask);

      var updateTask = doc.UpdateAsync(new Dictionary<string, object> {
        { "key1", FieldValue.Delete },
        { "key3", FieldValue.Delete },
        { "key5", FieldValue.Delete },
      });
      yield return AwaitSuccess(updateTask);

      var getTask = doc.GetSnapshotAsync(Source.Cache);
      yield return AwaitSuccess(getTask);
      DocumentSnapshot snapshot = getTask.Result;
      var expected = new Dictionary<string, object> {
        { "key2", "value2" },
        { "key4", "value4" },
      };
      Assert.That(snapshot.ToDictionary(), Is.EquivalentTo(expected));
    }
예제 #9
0
        /** UPDATE **/

        /** Finds product by id and updates it with new provided values to the firebase */
        public async Task <Product> Update(string id, Product productUpdate)
        {
            // Get document reference with given id from products collection
            DocumentReference productDocumentRef = firestoreDb.Collection(DB_PRODUCT_COLLECTION).Document(id);

            // Set up new data product in database
            Dictionary <string, object> productUpdateDictionary = new Dictionary <string, object>
            {
                { "Title", productUpdate.Title },
                { "Description", productUpdate.Description },
                { "Brand", productUpdate.Brand },
                { "Type", productUpdate.Type },
                { "Price", productUpdate.Price },
                { "PictureUrl", productUpdate.PictureUrl },
                { "Amount", productUpdate.Amount },
            };

            try
            {
                // Update product
                await productDocumentRef.UpdateAsync(productUpdateDictionary);
            }
            catch (Exception e)
            {
                // Return updated product
                return(productUpdate);
            }

            // Return updataded product
            return(productUpdate);
        }
        /** Get productStatus document reference and update it */
        public async Task <bool> UpdateProductStatus(ProductStatus productStatus)
        {
            // Get productStatus snapshot
            DocumentReference productDocumentRef = firestoreDb.Collection(DB_STATUS_COLLECTION).Document(productStatus.Id);

            // Set up new status data for productStatus in database
            Dictionary <string, object> productUpdateDictionary = new Dictionary <string, object>
            {
                { DB_STATUS_USER_ID, productStatus.UserId },
                { DB_STATUS_PRODUCT_ID, productStatus.Product.Id },
                { DB_STATUS_PRODUCT_STATUS, productStatus.Status },
                { DB_STATUS_PRODUCT_PURCHASE_DATE, productStatus.PurchaseDate }
            };

            try
            {
                // Update productStatus
                await productDocumentRef.UpdateAsync(productUpdateDictionary);
            }
            catch (Exception e)
            {
                // Return false because task was not successful
                return(false);
            }

            // Return true because task was successful
            return(true);
        }
예제 #11
0
        public async Task <HttpResponseMessage> DeleteAssignedNotification(MT_Virtual_Consultant_Booking VCMD)
        {
            Db = con.SurgeryCenterDb(VCMD.Slug);
            VCBookingResponse Response = new VCBookingResponse();

            try
            {
                MT_Notifications Notification          = new MT_Notifications();
                MT_Virtual_Consultant_Booking Booking  = new MT_Virtual_Consultant_Booking();
                List <MT_Notifications>       NotiList = new List <MT_Notifications>();
                Query         Qry          = Db.Collection("MT_Virtual_Consultant_Booking").WhereEqualTo("VCB_Unique_ID", VCMD.VCB_Unique_ID).WhereEqualTo("VCB_Is_Deleted", false).WhereEqualTo("VCB_Is_Active", true);
                QuerySnapshot ObjQuerySnap = await Qry.GetSnapshotAsync();

                if (ObjQuerySnap != null)
                {
                    Booking = ObjQuerySnap.Documents[0].ConvertTo <MT_Virtual_Consultant_Booking>();
                    if (VCMD.VCB_Notifications_Array != null && Booking.VCB_Notifications != null)
                    {
                        foreach (MT_Notifications noti in Booking.VCB_Notifications)
                        {
                            if (VCMD.VCB_Notifications_Array.Contains <string>(noti.NFT_Unique_ID) == false)
                            {
                                NotiList.Add(noti);
                            }
                        }
                    }
                }

                Dictionary <string, object> initialData = new Dictionary <string, object>
                {
                    { "VCB_Modify_Date", con.ConvertTimeZone(VCMD.VCB_TimeZone, Convert.ToDateTime(VCMD.VCB_Modify_Date)) },
                    { "VCB_TimeZone", VCMD.VCB_TimeZone },
                    { "VCB_Notifications", NotiList }
                };


                //Main section
                DocumentReference docRef = Db.Collection("MT_Virtual_Consultant_Booking").Document(VCMD.VCB_Unique_ID);
                WriteResult       Result = await docRef.UpdateAsync(initialData);

                if (Result != null)
                {
                    Response.Status  = con.StatusSuccess;
                    Response.Message = con.MessageSuccess;
                    Response.Data    = VCMD;
                }
                else
                {
                    Response.Status  = con.StatusNotInsert;
                    Response.Message = con.MessageNotInsert;
                    Response.Data    = null;
                }
            }
            catch (Exception ex)
            {
                Response.Status  = con.StatusFailed;
                Response.Message = con.MessageFailed + ", Exception : " + ex.Message;
            }
            return(ConvertToJSON(Response));
        }
예제 #12
0
        public async void AddFoodRecord(string userId, string item, string money, string bookDate)
        {
            DocumentReference docRef  = _db.Collection(userId).Document(bookDate);
            DocumentSnapshot  docShot = await _db.Collection(userId).Document(bookDate).GetSnapshotAsync();

            Dictionary <string, object> record = new Dictionary <string, object> {
                { "Id", Guid.NewGuid().ToString("N") },
                { "Name", item },
                { "Money", money.Contains(".") ? float.Parse(money) : Convert.ToInt32(money) }
            };

            if (docShot.Exists)
            {
                if (docShot.GetValue <List <Dictionary <string, object> > > ("list").Count > 0)
                {
                    await docRef.UpdateAsync("list", FieldValue.ArrayUnion(record));
                }
                else
                {
                    await docRef.SetAsync(new { list = new List <Dictionary <string, object> > ()
                                                {
                                                    record
                                                } });
                }
            }
            else
            {
                await docRef.SetAsync(new { list = new List <Dictionary <string, object> > ()
                                            {
                                                record
                                            } });
            }
        }
예제 #13
0
        //[Authorize(Roles ="SAdmin")]
        public async Task <HttpResponseMessage> PatientResetPassword(MT_User UMD)
        {
            //Db = con.SurgeryCenterDb(Objuser.Project_ID);
            UserResponse Response = new UserResponse();

            try
            {
                Dictionary <string, object> initialData = new Dictionary <string, object>
                {
                    { "UM_Password", UMD.UM_Password }
                };
                DocumentReference docRef = Db.Collection("MT_User").Document(UMD.UM_Unique_ID);
                WriteResult       Result = await docRef.UpdateAsync(initialData);

                if (Result != null)
                {
                    Response.Status  = con.StatusSuccess;
                    Response.Message = con.MessageSuccess;
                    Response.Data    = UMD;
                }
                else
                {
                    Response.Status  = con.StatusNotUpdate;
                    Response.Message = con.MessageNotUpdate;
                    Response.Data    = null;
                }
            }
            catch (Exception ex)
            {
                Response.Status  = con.StatusFailed;
                Response.Message = con.MessageFailed + ", Exception : " + ex.Message;
            }
            return(ConvertToJSON(Response));
        }
예제 #14
0
        public async Task <ActionResult> Submit()
        {
            try
            {
                string patientAutoId     = TempData["patientAutoId"].ToString();
                string appointmentAutoId = TempData["appointmentAutoId"].ToString();

                string Path = AppDomain.CurrentDomain.BaseDirectory + @"greenpaperdev-firebase-adminsdk-8k2y5-fb46e63414.json";
                Environment.SetEnvironmentVariable("GOOGLE_APPLICATION_CREDENTIALS", Path);
                FirestoreDb db = FirestoreDb.Create("greenpaperdev");

                DocumentReference docRef  = db.Collection("clinics").Document(GlobalSessionVariables.ClinicDocumentAutoId).Collection("appointments").Document(appointmentAutoId);
                DocumentSnapshot  docSnap = await docRef.GetSnapshotAsync();

                if (docSnap.Exists)
                {
                    Dictionary <string, object> data1 = new Dictionary <string, object>
                    {
                        { "completiondateChemist", DateTime.UtcNow },
                        { "statusChemist", "Completed" }
                    };

                    //await docRef.UpdateAsync( "completionMedicine",DateTime.UtcNow);
                    await docRef.UpdateAsync(data1);
                }
                // TODO: Add delete logic here

                return(RedirectToAction("Index", "Appointment"));
            }
            catch
            {
                return(View());
            }
        }
예제 #15
0
        private static async Task UpdateNestedFields(string project)
        {
            FirestoreDb db = FirestoreDb.Create(project);
            // [START fs_update_nested_fields]
            DocumentReference           frankDocRef = db.Collection("users").Document("frank");
            Dictionary <string, object> initialData = new Dictionary <string, object>
            {
                { "Name", "Frank" },
                { "Age", 12 }
            };

            Dictionary <string, object> favorites = new Dictionary <string, object>
            {
                { "Food", "Pizza" },
                { "Color", "Blue" },
                { "Subject", "Recess" },
            };

            initialData.Add("Favorites", favorites);
            await frankDocRef.SetAsync(initialData);

            // Update age and favorite color
            Dictionary <string, object> updates = new Dictionary <string, object>
            {
                { "Age", 13 },
                { "Favorites.Color", "Red" },
            };

            // Asynchronously update the document
            await frankDocRef.UpdateAsync(updates);

            // [END fs_update_nested_fields]
            Console.WriteLine("Updated the age and favorite color fields of the Frank document in the users collection.");
        }
예제 #16
0
        public static DeviceRegistration GetDevice(string token)
        {
            var documentSnapshot = db.Collection("devices").Document(token).GetSnapshotAsync().Result;
            var broken           = documentSnapshot.GetValue <object>("addresses_v2.p0.tokens");

            if (broken != null && broken.GetType().FullName.Contains("List"))
            {
                Console.WriteLine($"[FB] Invalid Tokens array found, deleting it {token}");

                //This will fail to be deserialized, so deleting the tokens array
                DocumentReference           docRef  = db.Collection("devices").Document(token);
                Dictionary <string, object> updates = new Dictionary <string, object>
                {
                    { "addresses_v2.p0.tokens", FieldValue.Delete }
                };
                docRef.UpdateAsync(updates).Wait();

                documentSnapshot = db.Collection("devices").Document(token).GetSnapshotAsync().Result;
                Console.WriteLine($"[FB] Invalid Tokens array successfully deleted {token}");
            }

            DeviceRegistration device = documentSnapshot.ConvertTo <DeviceRegistration>();

            device.ResetDirty();
            device.MigrateData();
            return(device);
        }
예제 #17
0
        public async Task <HttpResponseMessage> IsDeletedReference(MT_Knowledger_Base KCMD)
        {
            Db = con.SurgeryCenterDb(KCMD.Slug);
            KnowledgeBaseResponse Response = new KnowledgeBaseResponse();

            try
            {
                MT_Knowledger_Base KBase   = new MT_Knowledger_Base();
                List <KBReference> RefList = new List <KBReference>();
                Query         Qty          = Db.Collection("MT_Knowledger_Base").WhereEqualTo("KNB_Is_Deleted", false).WhereEqualTo("KNB_Is_Active", true).WhereEqualTo("KNB_Unique_ID", KCMD.KNB_Unique_ID);
                QuerySnapshot ObjQuerySnap = await Qty.GetSnapshotAsync();

                if (ObjQuerySnap != null)
                {
                    KBase = ObjQuerySnap.Documents[0].ConvertTo <MT_Knowledger_Base>();
                    if (KBase.KNB_References != null)
                    {
                        foreach (KBReference refe in KBase.KNB_References)
                        {
                            if (refe.KBR_Unique_ID != KCMD.KNB_References[0].KBR_Unique_ID)
                            {
                                RefList.Add(refe);
                            }
                        }
                    }
                }

                KCMD.KNB_Modify_Date = con.ConvertTimeZone(KCMD.KNB_TimeZone, Convert.ToDateTime(KCMD.KNB_Modify_Date));
                KCMD.KNB_References  = RefList;

                Dictionary <string, object> initialData = new Dictionary <string, object>
                {
                    { "KNB_Modify_Date", con.ConvertTimeZone(KCMD.KNB_TimeZone, Convert.ToDateTime(KCMD.KNB_Modify_Date)) },
                    { "KNB_References", KCMD.KNB_References },
                };

                DocumentReference docRef = Db.Collection("MT_Knowledger_Base").Document(KCMD.KNB_Unique_ID);
                WriteResult       Result = await docRef.UpdateAsync(initialData);

                if (Result != null)
                {
                    Response.Status  = con.StatusSuccess;
                    Response.Message = con.MessageSuccess;
                    Response.Data    = KCMD;
                }
                else
                {
                    Response.Status  = con.StatusNotInsert;
                    Response.Message = con.MessageNotInsert;
                    Response.Data    = null;
                }
            }
            catch (Exception ex)
            {
                Response.Status  = con.StatusFailed;
                Response.Message = con.MessageFailed + ", Exception : " + ex.Message;
            }
            return(ConvertToJSON(Response));
        }
예제 #18
0
        public async Task <HttpResponseMessage> UpdateAsync(MT_Staff_Members SMD)
        {
            Db = con.SurgeryCenterDb(SMD.Slug);
            StaffMResponse Response = new StaffMResponse();

            try
            {
                Dictionary <string, object> initialData = new Dictionary <string, object>
                {
                    { "Staff_Name", SMD.Staff_Name },
                    { "Staff_Last_Name", SMD.Staff_Last_Name },
                    { "Staff_Email", SMD.Staff_Email },
                    { "Staff_PhoneNo", SMD.Staff_PhoneNo },
                    { "Staff_AlternateNo", SMD.Staff_AlternateNo },
                    { "Staff_Emergency_ContactNo", SMD.Staff_Emergency_ContactNo },
                    { "Staff_Address1", SMD.Staff_Address1 },
                    { "Staff_Address1", SMD.Staff_Address2 },
                    { "Staff_City", SMD.Staff_City },
                    { "Staff_State", SMD.Staff_State },
                    { "Staff_Country", SMD.Staff_Country },
                    { "Staff_ZipCode", SMD.Staff_ZipCode },
                    { "Staff_Age", SMD.Staff_Age },
                    { "Staff_Sex", SMD.Staff_Sex },
                    { "Staff_DOB", SMD.Staff_DOB },
                    { "Staff_SSN_No", ObjectCrypto.Encrypt(ObjectCrypto.Encrypt(SMD.Staff_SSN_No, "sblw-3hn8-sqoy19"), "sblw-3hn8-sqoy19") },
                    { "Staff_DOJ", SMD.Staff_DOJ },
                    { "Staff_Emp_Code", SMD.Staff_Emp_Code },
                    { "Staff_Doc_Code", SMD.Staff_Doc_Code },
                    { "Staff_Designation", SMD.Staff_Designation },
                    { "Staff_Role_ID", SMD.Staff_Role_ID },
                    { "Staff_Role_Name", SMD.Staff_Role_Name },
                    { "Staff_Modify_Date", con.ConvertTimeZone(SMD.Staff_TimeZone, Convert.ToDateTime(SMD.Staff_Modify_Date)) },
                    { "Staff_Is_Active", SMD.Staff_Is_Active },
                    { "Staff_Is_Deleted", SMD.Staff_Is_Deleted }
                };

                DocumentReference docRef = Db.Collection("MT_Staff_Members").Document(SMD.Staff_Unique_ID);
                WriteResult       Result = await docRef.UpdateAsync(initialData);

                if (Result != null)
                {
                    Response.Status  = con.StatusSuccess;
                    Response.Message = con.MessageSuccess;
                    Response.Data    = SMD;
                }
                else
                {
                    Response.Status  = con.StatusNotUpdate;
                    Response.Message = con.MessageNotUpdate;
                    Response.Data    = null;
                }
            }
            catch (Exception ex)
            {
                Response.Status  = con.StatusFailed;
                Response.Message = con.MessageFailed + ", Exception : " + ex.Message;
            }
            return(ConvertToJSON(Response));
        }
예제 #19
0
        public async Task <HttpResponseMessage> Update(MT_Category_Master CMD)
        {
            Db = con.SurgeryCenterDb(CMD.Slug);
            CategoryResponse Response = new CategoryResponse();

            try
            {
                MT_Category_Master        CMaster  = new MT_Category_Master();
                List <MT_Category_Detail> CDetails = new List <MT_Category_Detail>();
                Query         ObjQuery             = Db.Collection("MT_Category_Master").WhereEqualTo("CM_UniqueID", CMD.CM_Unique_ID);
                QuerySnapshot ObjQuerySnap         = await ObjQuery.GetSnapshotAsync();

                if (ObjQuerySnap != null)
                {
                    CMaster = ObjQuerySnap.Documents[0].ConvertTo <MT_Category_Master>();
                    if (CMaster.CM_Detail != null)
                    {
                        foreach (MT_Category_Detail detail in CMaster.CM_Detail)
                        {
                            if (detail.CD_Unique_ID == CMD.CM_Detail[0].CD_Unique_ID)
                            {
                                detail.CD_Is_Assigned = CMD.CM_Detail[0].CD_Is_Assigned;
                                CDetails.Add(detail);
                            }
                            else
                            {
                                CDetails.Add(detail);
                            }
                        }
                    }
                }
                Dictionary <string, object> initialData = new Dictionary <string, object>
                {
                    { "CM_Detail", CDetails }
                };
                DocumentReference docRef = Db.Collection("MT_Category_Master").Document(CMD.CM_Unique_ID);
                WriteResult       Result = await docRef.UpdateAsync(initialData);

                if (Result != null)
                {
                    Response.Status  = con.StatusSuccess;
                    Response.Message = con.MessageSuccess;
                    Response.Data    = CMD;
                }
                else
                {
                    Response.Status  = con.StatusNotUpdate;
                    Response.Message = con.MessageNotUpdate;
                    Response.Data    = null;
                }
            }
            catch (Exception ex)
            {
                Response.Status  = con.StatusFailed;
                Response.Message = con.MessageFailed + ", Exception : " + ex.Message;
            }
            return(ConvertToJSON(Response));
        }
예제 #20
0
        public async Task <HttpResponseMessage> Edit(MT_System_EmailTemplates SEMD)
        {
            Db = con.SurgeryCenterDb(SEMD.Slug);
            SETemplatesResponse Response = new SETemplatesResponse();

            try
            {
                Dictionary <string, object> initialData = new Dictionary <string, object>
                {
                    { "SET_Description", SEMD.SET_Description },
                    { "SET_From_Email", SEMD.SET_From_Email },
                    { "SET_From_Name", SEMD.SET_From_Name },
                    { "SET_To", SEMD.SET_To },
                    { "SET_Header", SEMD.SET_Header },
                    { "SET_Message", SEMD.SET_Message },
                    { "SET_Footer", SEMD.SET_Footer },
                    { "SET_Modify_Date", con.ConvertTimeZone(SEMD.SET_TimeZone, Convert.ToDateTime(SEMD.SET_Modify_Date)) },
                    { "SET_TimeZone", SEMD.SET_TimeZone }
                };
                if (SEMD.SET_CC != null)
                {
                    if (SEMD.SET_CC.Length > 0)
                    {
                        initialData.Add("SET_CC", SEMD.SET_CC);
                    }
                }

                if (SEMD.SET_Bcc != null)
                {
                    if (SEMD.SET_Bcc.Length > 0)
                    {
                        initialData.Add("SET_Bcc", SEMD.SET_Bcc);
                    }
                }
                DocumentReference docRef = Db.Collection("MT_System_EmailTemplates").Document(SEMD.SET_Unique_ID);
                WriteResult       Result = await docRef.UpdateAsync(initialData);

                if (Result != null)
                {
                    Response.Status  = con.StatusSuccess;
                    Response.Message = con.MessageSuccess;
                    Response.Data    = SEMD;
                }
                else
                {
                    Response.Status  = con.StatusNotInsert;
                    Response.Message = con.MessageNotInsert;
                    Response.Data    = null;
                }
            }
            catch (Exception ex)
            {
                Response.Status  = con.StatusFailed;
                Response.Message = con.MessageFailed + ", Exception : " + ex.Message;
            }
            return(ConvertToJSON(Response));
        }
예제 #21
0
    public void botonIzquierdoPulsado()
    {
        DocumentReference docRef = db.Collection("animals").Document(nombres[izquierda].ToLower());

        docRef.UpdateAsync("count", FieldValue.Increment(1));

        izquierda = random.Next(imagenes.Length);
        nuevaImagen(botonIzquierda, izquierda);
    }
예제 #22
0
        async void Update_Array_Elements()
        {
            DocumentReference docref = db.Collection("Add_Aray").Document("myDoc");
            DocumentSnapshot  snap   = await docref.GetSnapshotAsync();

            if (snap.Exists)
            {
                await docref.UpdateAsync("My Array", FieldValue.ArrayUnion(123, "abcd", 456));
            }
        }
예제 #23
0
        private static async Task UpdateServerTimestamp(string project)
        {
            FirestoreDb db = FirestoreDb.Create(project);
            // [START fs_update_server_timestamp]
            DocumentReference cityRef = db.Collection("cities").Document("new-city-id");
            await cityRef.UpdateAsync("Timestamp", Timestamp.GetCurrentTimestamp());

            // [END fs_update_server_timestamp]
            Console.WriteLine("Updated the Timestamp field of the new-city-id document in the cities collection.");
        }
예제 #24
0
    public IEnumerator TestRemoveViaUpdateArrayRemove() {
      DocumentReference doc = TestDocument();
      var data = new Dictionary<string, object> { { "array", FieldValue.ArrayUnion(1L, 2L) } };
      yield return AwaitSuccess(doc.SetAsync(data));

      data = new Dictionary<string, object> { { "array", FieldValue.ArrayRemove(1L, 4L) } };
      AwaitSuccess(doc.UpdateAsync(data));
      yield return AssertExpectedDocument(
          doc, new Dictionary<string, object> { { "array", new List<object> { 2L } } });
    }
예제 #25
0
파일: Firestore.cs 프로젝트: HHIED/CAD
        public async Task UpdateSection(string username, Section section)
        {
            DocumentReference docRef = db.Collection("sections").Document(section.Id);

            string[] approvedBy = new string[] { username };
            Dictionary <string, object> updates = new Dictionary <string, object> {
                { "Title", section.Title },
                { "Text", section.Text },
                { "ApprovedBy", approvedBy },
                { "ApprovedAt", null }
            };
            await docRef.UpdateAsync(updates);

            await docRef.UpdateAsync("History", FieldValue.ArrayUnion(new HistoryItem {
                Action   = 1,
                ActionBy = username,
                ActionAt = Timestamp.GetCurrentTimestamp()
            }));
        }
예제 #26
0
        private async void UpdateDoc()
        {
            FirestoreDb db       = FirestoreDb.Create("cupofsoju-a47b2");
            string      updateid = null;
            // [START fs_delete_doc]
            CollectionReference usersRef = db.Collection("User");
            QuerySnapshot       snapshot = await usersRef.GetSnapshotAsync();

            foreach (DocumentSnapshot document in snapshot.Documents)
            {
                int id = 0;
                DocumentReference           cityRef            = db.Collection("User").Document(document.Id);
                Dictionary <string, object> documentDictionary = document.ToDictionary();
                switch (int.Parse(documentDictionary["bill"].ToString()))
                {
                case 0:
                    id = 1;
                    break;

                case 1:
                    id = 2;
                    break;

                case 2:
                    id = 3;
                    break;

                case 3:
                    id = 10;
                    break;

                case 4:
                    id = 14;
                    break;

                case 5:
                    id = 20;
                    break;
                }



                // Update age and favorite color
                Dictionary <string, object> updates = new Dictionary <string, object>
                {
                    { "todayLeft", id },
                };

                // Asynchronously update the document
                await cityRef.UpdateAsync(updates);
            }

            MessageBox.Show("수정 완료");
            UserParse();
        }
예제 #27
0
        public async Task Losse(string WinnerId, string LoserId, string game)                                                                         // approve lose by loser
        {
            Query         query = db.Collection("Match").WhereEqualTo("Game", game).WhereEqualTo("Winner", WinnerId).WhereEqualTo("Losser", LoserId); // gets query
            QuerySnapshot snap  = await query.GetSnapshotAsync();

            foreach (DocumentSnapshot doc in snap.Documents) // approve lose of all docs - should be only one
            {
                DocumentReference docref = db.Collection("Match").Document(doc.Id);
                await docref.UpdateAsync("Active", false); //update Active parameter
            }
        }
예제 #28
0
        public async Task <HttpResponseMessage> DeleteAction(MT_Patient_Intake PIMD)
        {
            Db = con.SurgeryCenterDb(PIMD.Slug);
            PatientIntakeResponse Response = new PatientIntakeResponse();

            try
            {
                List <Notification_Action> ActionList = new List <Notification_Action>();
                Query         ObjQuery     = Db.Collection("MT_Patient_Intake").WhereEqualTo("PIT_Is_Deleted", false).WhereEqualTo("PIT_Is_Active", true).WhereEqualTo("PIT_Unique_ID", PIMD.PIT_Unique_ID);
                QuerySnapshot ObjQuerySnap = await ObjQuery.GetSnapshotAsync();

                if (ObjQuerySnap != null)
                {
                    MT_Patient_Intake noti = ObjQuerySnap.Documents[0].ConvertTo <MT_Patient_Intake>();
                    if (noti.PIT_Actions != null)
                    {
                        foreach (Notification_Action action in noti.PIT_Actions)
                        {
                            if (action.NFA_Unique_ID != PIMD.PIT_Actions[0].NFA_Unique_ID)
                            {
                                ActionList.Add(action);
                            }
                        }
                    }
                }

                Dictionary <string, object> initialData = new Dictionary <string, object>
                {
                    { "PIT_Actions", ActionList }
                };

                DocumentReference docRef = Db.Collection("MT_Patient_Intake").Document(PIMD.PIT_Unique_ID);
                WriteResult       Result = await docRef.UpdateAsync(initialData);

                if (Result != null)
                {
                    Response.Status  = con.StatusSuccess;
                    Response.Message = con.MessageSuccess;
                    Response.Data    = PIMD;
                }
                else
                {
                    Response.Status  = con.StatusNotInsert;
                    Response.Message = con.MessageNotInsert;
                    Response.Data    = null;
                }
            }
            catch (Exception ex)
            {
                Response.Status  = con.StatusFailed;
                Response.Message = con.MessageFailed + ", Exception : " + ex.Message;
            }
            return(ConvertToJSON(Response));
        }
예제 #29
0
        async void setData()
        {
            dependentsList.Clear();
            for (int i = 0; i < groupNum; i++)
            {
                dependents = new Dependents();
                if (plans.type == "Familia")
                {
                    if (i > 5)
                    {
                        dependents.aditional = true;
                    }
                    else
                    {
                        dependents.aditional = false;
                    }
                }
                else
                {
                    dependents.aditional = true;
                }

                dependents.name     = textBoxes[i].Text;
                dependents.dtn      = maskedTextBoxes[i].Text;
                dependents.relation = comboBoxes[i].Text;
                dependentsList.Add(dependents);
            }


            Dictionary <string, object> data = new Dictionary <string, object>()
            {
                { "dependents", dependentsList },
                { "dueDate", int.Parse(txtDueDate.Text) },
                { "paymentMethod", cboPaymentMethod.Text }
            };


            Dictionary <string, object> invoiceData = new Dictionary <string, object>()
            {
                { "aditional", double.Parse(txtAditional.Text.Replace("R$ ", "")) },
                { "dueDate", int.Parse(txtDueDate.Text) },
                { "holder", txtHolder.Text },
                { "month", DateTime.Now.Month.ToString() },
                { "paymentMethod", cboPaymentMethod.Text },
                { "planName", txtPlanName.Text },
                { "status", "Pendente" },
                { "totalValue", double.Parse(txtTotalValue.Text.Replace("R$ ", "")) },
                { "value", txtPlanValue.Text },
            };

            await userReference.UpdateAsync(data);

            await invoiceReference.SetAsync(invoiceData);
        }
예제 #30
0
        void Delete_An_Element_Inside_An_Array()
        {
            DocumentReference           docref = db.Collection("Add_Aray").Document("myDoc");
            Dictionary <string, object> data   = new Dictionary <string, object>()
            {
                { "My Array", FieldValue.ArrayRemove(456, true) }
            };

            docref.UpdateAsync(data);
            MessageBox.Show("Done");
        }