예제 #1
0
        private void Saveexpensebutton_Click(object sender, EventArgs e)
        {
            if (!CrossConnectivity.Current.IsConnected)
            {
                Toast.MakeText(Activity, "Please check your internet connection", ToastLength.Long).Show();
                return;
            }
            if (string.IsNullOrEmpty(ítemSelected))
            {
                Toast.MakeText(Activity, "Add an item", ToastLength.Long).Show();
            }
            else if (string.IsNullOrWhiteSpace(desciptiontext.EditText.Text))
            {
                Toast.MakeText(Activity, "Add a description", ToastLength.Long).Show();
            }
            else if (string.IsNullOrWhiteSpace(amounttext.EditText.Text))
            {
                Toast.MakeText(Activity, "Add an amount", ToastLength.Long).Show();
            }
            else if (string.IsNullOrEmpty(datefield.Text))
            {
                Toast.MakeText(Activity, "Add a date", ToastLength.Long).Show();
            }
            else
            {
                if (FragTagName == "Add Expense")
                {
                    HashMap map = new HashMap();
                    map.Put("ItemName", ítemSelected);
                    map.Put("Description", desciptiontext.EditText.Text);
                    map.Put("Amount", amounttext.EditText.Text);
                    map.Put("Date", datefield.Text);
                    map.Put("DateDay", Convert.ToInt32(DaySelected));
                    map.Put("DateMonth", MonthSelected);
                    map.Put("DateYear", YearSelected);
                    map.Put("CreatedDate", DateTime.UtcNow.ToString());

                    map.Put("UserUid", CurrentUserUid);
                    DocumentReference docRef = database.Collection("ExpenseTable").Document();
                    docRef.Set(map);
                }
                else
                {
                    DocumentReference docRef = database.Collection("ExpenseTable").Document(expenseID);
                    docRef.Update("ItemName", ítemSelected);
                    docRef.Update("Description", desciptiontext.EditText.Text);
                    docRef.Update("Amount", amounttext.EditText.Text);
                    docRef.Update("Date", datefield.Text);
                    docRef.Update("DateDay", Convert.ToInt32(DaySelected));
                    docRef.Update("DateMonth", MonthSelected);
                    docRef.Update("DateYear", YearSelected);
                    docRef.Update("CreatedDate", DateTime.UtcNow.ToString());
                    // docRef.Update("CreatedDate", FieldValue.ServerTimestamp());
                }
                Vibrator vibrator = (Vibrator)Activity.GetSystemService(Context.VibratorService);
                vibrator.Vibrate(30);
                ((MainActivity)Activity).DisplayAndBindMonthRecyclerView();
                this.Dismiss();
            }
        }
예제 #2
0
        private void EditButton_Click(object sender, EventArgs e)
        {
            DocumentReference reference = AppDataHelper.GetFirestore().Collection("posts").Document(thisPost.ID);

            reference.Update("post_body", postEditText.Text);
            this.Dismiss();
        }
예제 #3
0
        public void AcceptFriend(string friendId)
        {
            DocumentReference documentReference =
                FirebaseBackend.FirebaseBackend
                .GetFireStore()
                .Collection("friends")
                .Document(currentUserID);

            documentReference.Update(friendId, true);

            DocumentReference documentReference2 =
                FirebaseBackend.FirebaseBackend
                .GetFireStore()
                .Collection("friends")
                .Document(friendId);

            documentReference2.Update(currentUserID, true);

            DocumentReference documentReference3 =
                FirebaseBackend.FirebaseBackend
                .GetFireStore()
                .Collection("invitations")
                .Document(currentUserID);

            documentReference3.Update(friendId, FieldValue.Delete());
        }
예제 #4
0
        public void OnEvent(Java.Lang.Object value, FirebaseFirestoreException error)
        {
            var snapshotQuery = (QuerySnapshot)value;

            if (!snapshotQuery.IsEmpty)
            {
                foreach (DocumentSnapshot snap in snapshotQuery.Documents)
                {
                    friendId = snap.Id.ToString();
                    DocumentReference documentReference =
                        FirebaseBackend.FirebaseBackend
                        .GetFireStore()
                        .Collection("invitations")
                        .Document(friendId);

                    documentReference.Update(currentUserID, true)
                    .AddOnSuccessListener(this)
                    .AddOnFailureListener(this);
                }
            }
            else
            {
                OnResult?.Invoke(this, new ResultEventArgs
                {
                    Result = "No user with such email"
                });
            }
        }
예제 #5
0
 public void UpdateData(object fields, CompletionHandler handler)
 {
     _documentReference.Update(fields.ToNativeFieldValues()).AddOnCompleteListener(new OnCompleteHandlerListener((task) =>
     {
         handler?.Invoke(task.IsSuccessful ? null : ExceptionMapper.Map(task.Exception));
     }));
 }
예제 #6
0
        public void OnSuccess(Java.Lang.Object result)
        {
            DocumentSnapshot snapshot = (DocumentSnapshot)result;

            if (!snapshot.Exists())
            {
                return;
            }

            DocumentReference likeReference = AppDataHelper.GetFirestore().Collection("posts").Document(postID);

            if (like)
            {
                likeReference.Update("likes." + AppDataHelper.GetFirebaseAuth().CurrentUser.Uid, true);
            }
            else
            {
                //check for null
                if (snapshot.Get("likes") == null)
                {
                    return;
                }

                var data = snapshot.Get("likes") != null?snapshot.Get("likes") : null;

                if (data != null)
                {
                    var dictionaryFromHashMap = new Android.Runtime.JavaDictionary <string, string>(data.Handle, JniHandleOwnership.DoNotRegister);

                    //retrieve our own id
                    string uid = AppDataHelper.GetFirebaseAuth().CurrentUser.Uid;

                    //check if our user ID is contained inside the dictionary
                    if (dictionaryFromHashMap.Contains(uid))
                    {
                        //remove our user ID to unlike the post
                        dictionaryFromHashMap.Remove(uid);

                        //update the hashmap withour our userid included
                        likeReference.Update("likes", dictionaryFromHashMap);
                    }
                }
            }
        }
예제 #7
0
        public void DeleteInvitation(string friendId)
        {
            DocumentReference documentReference3 =
                FirebaseBackend.FirebaseBackend
                .GetFireStore()
                .Collection("invitations")
                .Document(currentUserID);

            documentReference3.Update(friendId, FieldValue.Delete());
        }
예제 #8
0
        public void OnSuccess(Java.Lang.Object result)
        {
            DocumentSnapshot snapshot = (DocumentSnapshot)result;

            if (!snapshot.Exists())
            {
                return;
            }

            DocumentReference likesReference = AppDataHelper.GetFirestore().Collection("posts").Document(postID);

            if (Like)
            {
                likesReference.Update("likes." + AppDataHelper.GetFirebaseAuth().CurrentUser.Uid, true);
            }
            else
            {
                if (snapshot.Get("likes") == null)
                {
                    return;
                }

                var data = snapshot.Get("likes") != null?snapshot.Get("likes") : null;

                if (data != null)
                {
                    var dictionaryFromHashMap = new Android.Runtime.JavaDictionary <string, string>(data.Handle, JniHandleOwnership.DoNotRegister);

                    string uid = AppDataHelper.GetFirebaseAuth().CurrentUser.Uid;

                    if (dictionaryFromHashMap.Contains(uid))
                    {
                        dictionaryFromHashMap.Remove(uid);
                        likesReference.Update("likes", dictionaryFromHashMap);
                    }
                }
            }
        }
예제 #9
0
        public void SaveDishes(string documentId, string mealTitle, List <String> dishes)
        {
            HashMap content = new HashMap();

            for (int i = 0; i < dishes.Count; i++)
            {
                content.Put("" + (i + 1), dishes[i]);
            }
            DocumentReference document = CreateAccountActivity.FirestoreDb
                                         .Collection(collection)
                                         .Document(documentId);

            document.Update(mealTitle, content);
        }
예제 #10
0
        public Task <bool> UpdateUser(string TempEmail, string TempUsername)
        {
            TaskCompletionSource <bool> ResultCompletionSource = new TaskCompletionSource <bool>();
            DocumentReference           Path = Conn.Collection(usercollection).Document(TempEmail);

            Path.Update("username", TempUsername)
            .AddOnCompleteListener(new OnCompleteEventHandleListener((Android.Gms.Tasks.Task obj) =>
            {
                if (obj.IsSuccessful)
                {
                    ResultCompletionSource.SetResult(true);
                }
                else
                {
                    ResultCompletionSource.SetResult(false);
                }
            }));
            return(ResultCompletionSource.Task);
        }
예제 #11
0
        public void OnSuccess(Java.Lang.Object result)
        {
            var snapshot = (DocumentSnapshot)result;

            if (snapshot.Exists())
            {
                DocumentReference documentReference = FirebaseBackend.FirebaseBackend
                                                      .GetFireStore()
                                                      .Collection("friends")
                                                      .Document(Helpers.Helper.GetUserId());
                documentReference.Update(userId, FieldValue.Delete());

                DocumentReference documentReference2 = FirebaseBackend.FirebaseBackend
                                                       .GetFireStore()
                                                       .Collection("friends")
                                                       .Document(userId);
                documentReference2.Update(Helpers.Helper.GetUserId(), FieldValue.Delete());
            }
        }
예제 #12
0
        public async Task <string> EditData(String name, String lastName)
        {
            try
            {
                FirebaseFirestore database;
                string            uid = FirebaseAuth.Instance.CurrentUser.Uid;
                var app = FirebaseApp.Instance;
                database = FirebaseFirestore.GetInstance(app);

                DocumentReference docRef = database.Collection("utenti").Document(uid);

                var task = await docRef.Update("nome", name, "cognome", lastName);

                //return task.ToString(); //.update ritorna task<void>
                return("ok");
            }
            catch (Exception)
            {
                return("error");
            }
        }
예제 #13
0
        private void Buybtn_Click(object sender, EventArgs e)
        {
            selectedProduct.amount -= 1;

            database = databaseservice.GetDataBase();

            DocumentReference docRef = database.Collection("products").Document(selectedProduct.ID);

            docRef.Update("amount", selectedProduct.amount);

            //SecondPageActivity loggedinuser = new SecondPageActivity();



            var chars = "QWERTYUIOPASDFGHJKLZXCVBNM1234567890";

            var stringchars = new char[5];

            var rand = new Random();

            for (int i = 0; i < stringchars.Length; i++)
            {
                stringchars[i] = chars[rand.Next(chars.Length)];
            }

            var orderidstring = new String(stringchars);


            HashMap map = new HashMap();

            map.Put("orderid", orderidstring);
            map.Put("buyername", username);
            map.Put("productname", selectedProduct.productname);
            map.Put("productamount", 1);
            map.Put("productprice", 250);
            map.Put("buyerlocation", "Debere Abay St.");
            map.Put("buyerphone", "0944194561");
            //map.Put("profileimage", Profileimg);

            docRef = database.Collection("orders").Document();

            docRef.Set(map);


            var trans = SupportFragmentManager.BeginTransaction();
            var buyproductfragment = new BuyFragment();

            buyproductfragment.Show(trans, "buyproduct");

            var SMSMessenger = CrossMessaging.Current.SmsMessenger;

            if (SMSMessenger.CanSendSmsInBackground)
            {
                SMSMessenger.SendSmsInBackground("251944194561", $"This is from Burnos Clothes.\n\nYour Order number is {orderidstring.ToUpper()}.");
            }


            try
            {
                MailMessage mail       = new MailMessage();
                SmtpClient  SmtpServer = new SmtpClient("smtp.gmail.com");

                mail.From = new MailAddress("*****@*****.**");
                mail.To.Add("*****@*****.**");
                mail.Subject = "Burnos Clothes Order Successful";
                mail.Body    = $"Well hello there {username}. This is from Selvaj clothes.\nThis is ur Order ID:\n\n{orderidstring}\n\nUse this id to recieve ur package from our store when ur products arrives";

                SmtpServer.Port        = 587;
                SmtpServer.Host        = "smtp.gmail.com";
                SmtpServer.EnableSsl   = true;
                SmtpServer.Credentials = new System.Net.NetworkCredential("*****@*****.**", "burnos123");

                ServicePointManager.ServerCertificateValidationCallback = delegate(object zsender, X509Certificate certificate, X509Chain chain, System.Net.Security.SslPolicyErrors sslpolicyerrors)
                {
                    return(true);
                };

                SmtpServer.Send(mail);
            }
            catch (Exception ex)
            {
                Toast.MakeText(this, ex.ToString(), ToastLength.Long);
            }



            //var trans = SupportFragmentManager.BeginTransaction();
            //var buyproductfragment = new BuyFragment();

            //buyproductfragment.Show(trans, "buyproduct");
        }
예제 #14
0
        private void UpdateButton_Click(object sender, System.EventArgs e)
        {
            DocumentReference phoneref = GetFireStore().Collection("Users").Document("R6t1ueRzrVUc9MnHlK3P");

            phoneref.Update("phone_number.fax", "+45383638738");
        }
        public void OnSuccess(Java.Lang.Object result)
        {
            var    snapshot  = (DocumentSnapshot)result;
            string messageId = FirebaseBackend.FirebaseBackend.GetFireStore()
                               .Collection("do not exits")
                               .Document(Helpers.Helper.GenerateMessageId()).Id.ToString();
            DocumentReference documentRef = FirebaseBackend.FirebaseBackend.GetFireStore()
                                            .Collection("chats")
                                            .Document(conversationId);

            if (!snapshot.Exists())
            {
                HashMap hashMap = new HashMap();
                hashMap.Put(messageId, null);
                documentRef.Set(hashMap);
                documentRef.Update(messageId.ToString() + "." + "message_body", body);
                documentRef.Update(messageId.ToString() + "." + "message_date", DateTime.Now.ToString("dd MM yyyy HH:mm:ss"));
                documentRef.Update(messageId.ToString() + "." + "from", from);
                documentRef.Update(messageId.ToString() + "." + "to", to);
                documentRef.Update(messageId.ToString() + "." + "to_fullname", toFullname);
                documentRef.Update(messageId.ToString() + "." + "to_image_id", toUrl);
                documentRef.Update(messageId.ToString() + "." + "from_fullname", Helpers.Helper.GetFullName());
                documentRef.Update(messageId.ToString() + "." + "from_image_id", Helpers.Helper.GetImageUrl());
            }
            else
            {
                HashMap hashMap = new HashMap();
                hashMap.Put(messageId, null);
                documentRef.Update(messageId, null);
                documentRef.Update(messageId.ToString() + "." + "message_body", body);
                documentRef.Update(messageId.ToString() + "." + "message_date", DateTime.Now.ToString("dd MM yyyy HH:mm:ss"));
                documentRef.Update(messageId.ToString() + "." + "from", from);
                documentRef.Update(messageId.ToString() + "." + "to", to);
                documentRef.Update(messageId.ToString() + "." + "to_fullname", toFullname);
                documentRef.Update(messageId.ToString() + "." + "to_image_id", toUrl);
                documentRef.Update(messageId.ToString() + "." + "from_fullname", Helpers.Helper.GetFullName());
                documentRef.Update(messageId.ToString() + "." + "from_image_id", Helpers.Helper.GetImageUrl());
            }
            OnSendingResult?.Invoke(this, new ResultEventArgs
            {
                Result = "Message sent successfuly"
            });
        }