예제 #1
0
 public void SetData(object documentData, CompletionHandler handler)
 {
     _documentReference.Set(documentData.ToNativeFieldValues()).AddOnCompleteListener(new OnCompleteHandlerListener((task) =>
     {
         handler?.Invoke(task.IsSuccessful ? null : ExceptionMapper.Map(task.Exception));
     }));
 }
예제 #2
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();
            }
        }
예제 #3
0
        public async Task <string> AddTransaction(string category, string money)
        {
            try
            {
                FirebaseFirestore database;
                string            uid = FirebaseAuth.Instance.CurrentUser.Uid;
                var app = FirebaseApp.Instance;
                database = FirebaseFirestore.GetInstance(app);
                string date = DateTime.Today.ToString("dd/MM/yyyy");
                string type = "Earnings";



                HashMap map = new HashMap();
                map.Put("tipologia", type);
                map.Put("cifra", money);
                map.Put("categoria", category);
                map.Put("data", date);
                map.Put("createdAt", Timestamp.Now()); //servirà per ordinare i documenti quando si estraggono


                DocumentReference docRef = database.Collection("utenti").Document(uid).Collection("transazioni").Document();
                var task = await docRef.Set(map);

                return("ok");
            }
            catch (Exception e)
            {
                //Debug.WriteLine($"Error:{e}");
                return("error");
            }
        }
예제 #4
0
        private void Cart_Click(object sender, EventArgs e)
        {
            if (productadded)
            {
                Intent cartpage = new Intent(this, typeof(CartActivity));
                //productpage.PutExtra("productdetail", JsonConvert.SerializeObject(selectedproduct));
                StartActivity(cartpage);
            }
            else
            {
                DocumentReference docRef = database.Collection("carts").Document();

                HashMap map = new HashMap();
                map.Put("buyername", username);
                map.Put("productname", selectedProduct.productname);
                map.Put("imageurl", selectedProduct.imageurl);
                map.Put("unitprice", 250);
                //map.Put("productimgurl", selectedProduct.);

                docRef.Set(map);

                Toast.MakeText(this, "Product Added to Cart", ToastLength.Long).Show();

                cart.Text = "Go To Cart";
            }
            //database = databaseservice.GetDataBase();

            //User buyinguser = new User();

            //buyinguser = SecondPageActivity.loggedinuser;

            //username = buyinguser.Fullname;
        }
예제 #5
0
        public async Task <string> SignUp(string email, string password, string name, string lastName)
        {
            try
            {
                var user = await FirebaseAuth.Instance.CreateUserWithEmailAndPasswordAsync(email, password);

                var token = await user.User.GetIdTokenAsync(false);

                //per salvare dati nella collection users
                if (token.Token != null)
                {
                    FirebaseFirestore database;
                    string            uid = FirebaseAuth.Instance.CurrentUser.Uid;

                    var app = FirebaseApp.Instance;

                    database = FirebaseFirestore.GetInstance(app);

                    HashMap map = new HashMap();
                    map.Put("email", email);
                    map.Put("nome", name);
                    map.Put("cognome", lastName);

                    DocumentReference docRef = database.Collection("utenti").Document(uid);
                    await docRef.Set(map);
                }

                return(token.Token);
            }
            catch (Exception e)
            {
                return(null);
            }
        }
예제 #6
0
        private void SubmitButton_Click(object sender, EventArgs e)
        {
            HashMap postMap = new HashMap();

            postMap.Put("author", AppDataHelper.GetFullName());
            postMap.Put("owner_id", AppDataHelper.GetFirebaseAuth().CurrentUser.Uid);
            postMap.Put("post_date", DateTime.Now.ToString());
            postMap.Put("post_body", postEditText.Text);

            DocumentReference newPostRef = AppDataHelper.GetFirestore().Collection("posts").Document();
            string            postKey    = newPostRef.Id;

            postMap.Put("image_id", postKey);


            ShowProgressDialogue("Saving Information ...");

            // Save Post Image to Firebase Storaage
            StorageReference storageReference = null;

            if (fileBytes != null)
            {
                storageReference = FirebaseStorage.Instance.GetReference("postImages/" + postKey);
                storageReference.PutBytes(fileBytes)
                .AddOnSuccessListener(taskCompletionListeners)
                .AddOnFailureListener(taskCompletionListeners);
            }

            // Image Upload Success Callback
            taskCompletionListeners.Sucess += (obj, args) =>
            {
                if (storageReference != null)
                {
                    storageReference.DownloadUrl.AddOnSuccessListener(downloadUrlListener);
                }
            };

            // Image Download URL Callback
            downloadUrlListener.Sucess += (obj, args) =>
            {
                string downloadUrl = args.Result.ToString();
                postMap.Put("download_url", downloadUrl);

                // Save post to Firebase Firestore
                newPostRef.Set(postMap);
                CloseProgressDialogue();
                Finish();
            };


            // Image Upload Failure Callback
            taskCompletionListeners.Failure += (obj, args) =>
            {
                Toast.MakeText(this, "Upload was not completed", ToastLength.Short).Show();
            };
        }
예제 #7
0
        public void saveMtd()
        {
            HashMap map = new HashMap();

            map.Put("Name", "Kalpesh..!!!");

            DocumentReference docRef = database.Collection("users").Document();

            docRef.Set(map);
        }
예제 #8
0
        public String CreateDocument(DateTime date, string user)
        {
            // Check dateTime
            DocumentReference document = CreateAccountActivity.FirestoreDb.Collection(collection).Document();
            HashMap           data     = new HashMap();

            data.Put(userKey, user);
            data.Put(dateKey, date.Date.ToString(DateTimeFormat));
            document.Set(data);
            return(document.Id);
        }
예제 #9
0
        /// <summary>
        /// saves a score to a collection
        /// </summary>
        /// <param name="cName">the collection</param>
        /// <param name="score">the score</param>
        public void SaveScoreToCollection(string cName, Score score)
        {
            Hashtable data = new Hashtable();

            data.Put("Name", score.Name);
            data.Put("Score", score.HighestValue);
            data.Put("Key", score.Key);
            DocumentReference cr = firestore.Collection(cName).Document(score.Key.ToString());

            cr.Set(data);
        }
예제 #10
0
        private void RegisterButton_Click(object sender, EventArgs e)
        {
            fullname = fullnameText.EditText.Text;
            email    = emailText.EditText.Text;
            password = passwordText.EditText.Text;
            confirm  = confirmPasswordText.EditText.Text;

            if (fullname.Length < 4)
            {
                Toast.MakeText(this, "Please enter a valid name", ToastLength.Short).Show();
                return;
            }
            else if (!email.Contains("@"))
            {
                Toast.MakeText(this, "Please enter a valid email address", ToastLength.Short).Show();
                return;
            }
            else if (password.Length < 8)
            {
                Toast.MakeText(this, "Please enter a password upto 8 characters", ToastLength.Short).Show();
                return;
            }
            else if (password != confirm)
            {
                Toast.MakeText(this, "Password does not match, please make correction", ToastLength.Short).Show();
                return;
            }

            // Perform Registration
            ShowProgressDialogue("Registering you..");
            mAuth.CreateUserWithEmailAndPassword(email, password).AddOnSuccessListener(this, taskCompletionListeners)
            .AddOnFailureListener(this, taskCompletionListeners);

            // Registration Success Callback
            taskCompletionListeners.Sucess += (success, args) =>
            {
                HashMap userMap = new HashMap();
                userMap.Put("email", email);
                userMap.Put("fullname", fullname);

                DocumentReference userReference = database.Collection("users").Document(mAuth.CurrentUser.Uid);
                userReference.Set(userMap);
                CloseProgressDialogue();
                StartActivity(typeof(MainActivity));
                Finish();
            };

            // Registration Failure Callback
            taskCompletionListeners.Failure += (failure, args) =>
            {
                CloseProgressDialogue();
                Toast.MakeText(this, "Registartion Failed : " + args.Cause, ToastLength.Short).Show();
            };
        }
예제 #11
0
        private void AddToCart_Click(object sender, EventArgs e)
        {
            DocumentReference docref = db.Collection("Orders").Document();
            Dictionary <string, Java.Lang.Object> order = new Dictionary <string, Java.Lang.Object>
            {
                { "Item", current.Name },
                { "Price", current.Price.ToString() },
                { "Uid", auth.CurrentUser.Uid }
            };

            docref.Set(order);
        }
        //public async Task<string> GetAllCurrentInfo()
        //{
        //    DocumentReference docRef = database.Collection("cities").Document("SF");
        //    DocumentSnapshot snapshot = await docRef.SnapshotAsync();
        //    return "";
        //}

        private void SaveButton_Click(object sender, System.EventArgs e)
        {
            HashMap map = new HashMap();

            map.Put("Type", Type.Text);
            map.Put("Breed", Breed.Text);
            map.Put("Name", Name.Text);
            map.Put("Info", Info.Text);

            DocumentReference docRef = database.Collection("Infos").Document();

            docRef.Set(map);
        }
예제 #13
0
        //Building the AddStudent Screen
        private void AddStudentButton_Click(object sender, EventArgs e)
        {
            if (IsValidName(NameAddStudentET.Text) && MyStuff.isValidEmail(EmailAddStudentET.Text, this) && currGroup != "Choose Group")
            {
                if (Parent1NameAddStudentET.Text != "" && Parent2NameAddStudentET.Text != "")
                {
                    student = new Student(NameAddStudentET.Text, PhoneNumAddStudentET.Text, EmailAddStudentET.Text, Parent1NameAddStudentET.Text, Parent2NameAddStudentET.Text, AddStudentExplenationET.Text, currGroup);
                }
                if (Parent1NameAddStudentET.Text == "" && Parent2NameAddStudentET.Text != "")
                {
                    student = new Student(NameAddStudentET.Text, PhoneNumAddStudentET.Text, EmailAddStudentET.Text, Parent2NameAddStudentET.Text, AddStudentExplenationET.Text, currGroup);
                }
                if (Parent1NameAddStudentET.Text != "" && Parent2NameAddStudentET.Text == "")
                {
                    student = new Student(NameAddStudentET.Text, PhoneNumAddStudentET.Text, EmailAddStudentET.Text, Parent1NameAddStudentET.Text, AddStudentExplenationET.Text, currGroup);
                }
                if (Parent1NameAddStudentET.Text == "" && Parent2NameAddStudentET.Text == "")
                {
                    student = new Student(NameAddStudentET.Text, PhoneNumAddStudentET.Text, EmailAddStudentET.Text, AddStudentExplenationET.Text, currGroup);
                }

                HashMap map = new HashMap();
                map.Put("Name", student.name);
                map.Put("PhoneNum", student.phoneNumber);
                map.Put("Email", student.email);
                map.Put("Parent1", student.parentName1);
                map.Put("Parent2", student.parentName2);
                map.Put("Notes", student.notes);
                map.Put("Group", student.group);
                DocumentReference docref = database.Collection("Users").Document(admin.email).Collection("Students").Document(student.name + " " + student.phoneNumber);
                docref.Set(map);
                Toasty.Config.Instance
                .TintIcon(true)
                .SetToastTypeface(Typeface.CreateFromAsset(Assets, "Katanf.ttf"));
                Toasty.Success(this, "Student Added Sucesfully", 5, true).Show();
                NameAddStudentET.Text        = "";
                PhoneNumAddStudentET.Text    = "05";
                EmailAddStudentET.Text       = "";
                Parent1NameAddStudentET.Text = "";
                Parent2NameAddStudentET.Text = "";
                AddStudentExplenationET.Text = "";
                spin.SetSelection(0);
            }
            else
            {
                Toasty.Config.Instance
                .TintIcon(true)
                .SetToastTypeface(Typeface.CreateFromAsset(Assets, "Katanf.ttf"));
                Toasty.Error(this, "Input InValid", 5, true).Show();
            }
        }
예제 #14
0
        // Stores order in datrtabase
        private void AddToCart_Click(object sender, EventArgs e)
        {
            DocumentReference docref = db.Collection("Orders").Document();
            Dictionary <string, Java.Lang.Object> order = new Dictionary <string, Java.Lang.Object>
            {
                { "Item", current.Name },
                { "Price", (current.Price * (decimal)orderQuantity).ToString() },
                { "Quantity", quantity.Text },
                { "Uid", auth.CurrentUser.Uid }
            };

            docref.Set(order);

            Snackbar.Make(rootView, "Added to cart!", Snackbar.LengthShort).Show();
        }
예제 #15
0
        private void SetupPrototipeCollections()
        {
            //To będzie do zmiany
            DocumentReference reff = FirebaseBackend.FirebaseBackend.GetFireStore()
                                     .Collection("invitations").Document(auth.CurrentUser.Uid);
            HashMap hash = new HashMap();

            hash.Put("none", true);
            reff.Set(hash);

            DocumentReference refff = FirebaseBackend.FirebaseBackend.GetFireStore()
                                      .Collection("friends").Document(auth.CurrentUser.Uid);
            HashMap hashh = new HashMap();

            hashh.Put("none", true);
            refff.Set(hashh);
        }
예제 #16
0
 public bool SetPerson(int id, string name, int age)
 {
     try
     {
         HashMap map = new HashMap();
         map.Put("Name", name);
         map.Put("PersonId", id);
         map.Put("Age", age);
         map.Put("author", CurrentUser.Uid);
         DocumentReference docRef = FirestoreService.Instance.Collection("persons").Document();
         docRef.Set(map);
         return(true);
     }catch (Java.Lang.Exception ex)
     {
         string msg = ex.Message;
         return(false);
     }
 }
        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"
            });
        }
예제 #18
0
        //Builds The Screen
        private void AddTrainingButton_Click(object sender, EventArgs e)
        {
            Exercise ex  = new Exercise(AddTrainingNameET.Text, AddTrainingExplenationET.Text);
            HashMap  map = new HashMap();

            map.Put("Name", ex.name);
            map.Put("Explenation", ex.explenatiotn);
            DocumentReference DocRef = database.Collection("Users").Document(admin.email).Collection("Exercises").Document(ex.name);

            DocRef.Set(map);
            Toasty.Config.Instance
            .TintIcon(true)
            .SetToastTypeface(Typeface.CreateFromAsset(Assets, "Katanf.ttf"));
            Toasty.Success(this, "Exercise was added secessfully", 5, true).Show();
            Intent intent1 = new Intent(this, typeof(MainPageActivity));

            intent1.PutExtra("Email", admin.email);
            StartActivity(intent1);
        }
예제 #19
0
        private void Cart_Click(object sender, EventArgs e)
        {
            if (productadded)
            {
                //
                //
                //
                //
                //
                //
                //
                //Goto cart page to do!!!
                //
                //
                //
                //
                //
                //
            }
            else
            {
                DocumentReference docRef = database.Collection("carts").Document();

                HashMap map = new HashMap();
                map.Put("buyername", username);
                map.Put("productname", selectedProduct.productname);
                map.Put("productamount", 1);
                map.Put("unitprice", 250);

                docRef.Set(map);

                Toast.MakeText(this, "Product Added to Cart", ToastLength.Long).Show();

                cart.Text = "Go To Cart";
            }
            //database = databaseservice.GetDataBase();

            //User buyinguser = new User();

            //buyinguser = SecondPageActivity.loggedinuser;

            //username = buyinguser.Fullname;
        }
예제 #20
0
 private void SendBtn_Click(object sender, EventArgs e)
 {
     if (DateBtn.Text != "Date")
     {
         //add to firebase
         HashMap map = new HashMap();
         map.Put("Date", DateBtn.Text);
         map.Put("Group", LocationET.Text + " " + TimeBtn.Text + " " + AgeET.Text);
         DocumentReference docref = database.Collection("Users").Document(admin.email).Collection("Meetings").Document();
         docref.Set(map);
         HashMap map2 = new HashMap();
         Toasty.Success(this, "Meeting Added Sucesfully", 5, true).Show();
         Intent intent1 = new Intent(this, typeof(MainPageActivity));
         StartActivity(intent1);
     }
     else
     {
         Toasty.Error(this, "Pick Date", 5, true).Show();
     }
 }
예제 #21
0
 private void Btn_Click(object sender, System.EventArgs e)
 {
     if (InputLegit(NameET.Text, PhoneNumET.Text))
     {
         HashMap map = new HashMap();
         map.Put("Name", NameET.Text);
         map.Put("PhoneNum", PhoneNumET.Text);
         map.Put("Taken", true);
         DocumentReference docref = database.Collection("Seats").Document(currI + "," + currK);
         docref.Set(map);
         Toast.MakeText(this, "Successful", ToastLength.Long).Show();
         d.Dismiss();
     }
     else
     {
         Toast.MakeText(this, "Input InValid", ToastLength.Short).Show();
         NameET.Text     = "";
         PhoneNumET.Text = "05";
     }
 }
예제 #22
0
        private void SaveButton_Click(object sender, System.EventArgs e)
        {
            HashMap phoneMap = new HashMap();

            phoneMap.Put("mobile", "+16373645383");
            phoneMap.Put("work", "+236894948");
            phoneMap.Put("home", "+3525736523");

            HashMap map = new HashMap();

            map.Put("full_name", "Uchenna Nnodim");
            map.Put("email", "*****@*****.**");
            map.Put("phone_number", phoneMap);

            FirebaseFirestore database;

            database = GetFireStore();

            DocumentReference docRef = database.Collection("Users").Document();

            docRef.Set(map);
        }
예제 #23
0
 //Building Register Screen
 private void LoginButton_Click(object sender, System.EventArgs e)
 {
     if (!MyStuff.Emails.Contains(MailLoginET.Text))
     {
         //validation of input
         if (MyStuff.IsValidName(NameLoginET.Text, NameLoginET, this) && MyStuff.IsValidSport(SportLoginET.Text, this) & MyStuff.isValidEmail(MailLoginET.Text, this) && PhoneNumberLoginET.Text.Length == 10 && PhoneNumberLoginET.Text.ToString().All(c => Char.IsLetterOrDigit(c)))
         {
             string image = "";
             try { image = MyStuff.ConvertBitMapToString(BitProfilePic); }
             catch { };
             Toasty.Config.Instance
             .TintIcon(true)
             .SetToastTypeface(Typeface.CreateFromAsset(Assets, "Katanf.ttf"));
             admin = new Admin1(SportLoginET.Text, NameLoginET.Text, PhoneNumberLoginET.Text, MailLoginET.Text, image);
             HashMap map = new HashMap();
             map.Put("Name", admin.name);
             map.Put("EMail", admin.email);
             map.Put("PhoneNum", admin.phoneNumber);
             map.Put("Sport", admin.sport);
             map.Put("Profile", admin.ProfilePic);
             DocumentReference DocRef = database.Collection("Users").Document(admin.email);
             DocRef.Set(map);
             MyStuff.PutToShared(admin);
             Intent intent1 = new Intent(this, typeof(MainPageActivity));
             Toasty.Success(this, "Edited successfully", 5, true).Show();
             //
             SmsManager sm = SmsManager.Default;
             sm.SendTextMessage(PhoneNumberLoginET.Text /*מספר טלפון*/, null, "Welcome to T-POV, " + NameLoginET.Text + "!" /*תכולה*/, null, null);
             //
             StartActivity(intent1);
         }
     }
     else
     {
         Toasty.Error(this, "Email Already In Database", 5, true).Show();
         MailLoginET.Text = "";
     }
 }
예제 #24
0
 //Building the AddGroup Screen
 private void AddGroupButton_Click(object sender, EventArgs e)
 {
     if (InputValid(LocationAddGroupET.Text, AgeAddGroupET.Text, GroupLevelAddGroupET.Text, c))
     {
         //add to firebase
         Group   group = new Group(AgeAddGroupET.Text, GroupLevelAddGroupET.Text, CompRBAddGroup.Selected, LocationAddGroupET.Text, AddGroupTimeButton.Text);
         HashMap map   = new HashMap();
         map.Put("Location", group.Location);
         map.Put("Level", group.geoupLevel);
         map.Put("Age", group.age);
         map.Put("Comp", group.competetive);
         map.Put("Time", group.time);
         DocumentReference docref = database.Collection("Users").Document(admin.email).Collection("Groups").Document(group.Location + " " + group.time + " " + group.age);
         docref.Set(map);
         HashMap map2 = new HashMap();
         Toasty.Config.Instance
         .TintIcon(true)
         .SetToastTypeface(Typeface.CreateFromAsset(Assets, "Katanf.ttf"));
         Toasty.Success(this, "Group Added Sucesfully", 5, true).Show();
         Intent intent1 = new Intent(this, typeof(MainPageActivity));
         StartActivity(intent1);
     }
 }
예제 #25
0
 private void SaveButton_Click(object sender, EventArgs e)
 {
     if (InputValid(LocET.Text, AgeET.Text, LVLET.Text, c))
     {
         //add to firebase
         Group   group = new Group(AgeET.Text, LVLET.Text, CompRB.Checked, LocET.Text, TimeButton.Text);
         HashMap map   = new HashMap();
         map.Put("Location", group.Location);
         map.Put("Level", group.geoupLevel);
         map.Put("Age", group.age);
         map.Put("Comp", group.competetive);
         map.Put("Time", group.time);
         DocumentReference docref = database.Collection("Users").Document(admin1.email).Collection("Groups").Document(group.Location + " " + group.time + " " + group.age);
         docref.Set(map);
         HashMap map2 = new HashMap();
         Toasty.Config.Instance
         .TintIcon(true)
         .SetToastTypeface(Typeface.CreateFromAsset(Assets, "Katanf.ttf"));
         Toasty.Success(this, "Group Added Sucesfully", 5, true).Show();
         GrouD.Dismiss();
         d.Dismiss();
         this.Recreate();
     }
 }
예제 #26
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");
        }
예제 #27
0
        private void RegisterButton_Click(object sender, EventArgs e)
        {
            fullname    = fullnameText.EditText.Text;
            email       = emailText.EditText.Text;
            password    = passwordText.EditText.Text;
            confirmPass = confirmPasswordText.EditText.Text;

            if (fullname.Length < 4)
            {
                Toast.MakeText(this, "Please enter a valid name.", ToastLength.Short).Show();
                return;
            }
            else if (!email.Contains('@'))
            {
                Toast.MakeText(this, "Please enter a valid email address.", ToastLength.Short).Show();
                return;
            }
            else if (password.Length < 8)
            {
                Toast.MakeText(this, "Password must be 8 characters long.", ToastLength.Short).Show();
                passwordText.EditText.Text        = "";
                confirmPasswordText.EditText.Text = "";
                return;
            }
            else if (confirmPass != password)
            {
                Toast.MakeText(this, "Password does not match.", ToastLength.Short).Show();
                passwordText.EditText.Text        = "";
                confirmPasswordText.EditText.Text = "";
                return;
            }


            //Create user to firebase/REGISTRATION
            ShowProgressDialogue("Registering...");
            mAuth.CreateUserWithEmailAndPassword(email, password)
            .AddOnSuccessListener(this, taskCompletionListener)
            .AddOnFailureListener(this, taskCompletionListener);


            //REGISTRATION SUCCESS CALLBACK
            taskCompletionListener.Success += (success, args) =>
            {
                //add the records of the user
                HashMap userMap = new HashMap();
                userMap.Put("email", email);
                userMap.Put("fullname", fullname);

                //Since the registration is successfull, the current user is not null.
                DocumentReference userReference = database.Collection("users").Document(mAuth.CurrentUser.Uid);

                //Save the usermap to the userReference
                userReference.Set(userMap);
                CloseProgressDialogue();
                StartActivity(typeof(MainActivity));
                Finish();
            };

            //REGISTRATION FAILURE CALLBACK
            taskCompletionListener.Failure += (failure, args) =>
            {
                //Show message why the registration failed
                CloseProgressDialogue();
                Toast.MakeText(this, "Registration failed : " + args.Cause, ToastLength.Short).Show();
            };
        }
예제 #28
0
        void ConnectViews()
        {
            Fnametext   = (TextInputLayout)FindViewById(Resource.Id.fullnametext);
            emtext      = (TextInputLayout)FindViewById(Resource.Id.emailtext);
            passtext    = (TextInputLayout)FindViewById(Resource.Id.passwordtext);
            submit      = (Button)FindViewById(Resource.Id.submit_btn);
            login       = (Button)FindViewById(Resource.Id.login_btn);
            googlelogin = (Button)FindViewById(Resource.Id.googlelogin_btn);
            profimg     = (ImageView)FindViewById(Resource.Id.profileiv);

            gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DefaultSignIn)
                  .RequestIdToken("228992356302-n0p15tka3tqvhps5e7ra7scrs6fqg0p0.apps.googleusercontent.com")
                  .RequestEmail().Build();

            googleapiclient = new GoogleApiClient.Builder(this).AddApi(Auth.GOOGLE_SIGN_IN_API, gso).Build();

            googleapiclient.Connect();


            submit.Click += (sender, e) =>
            {
                if (imageArray == null)
                {
                    imageArray = System.IO.File.ReadAllBytes("Resources/Images/DefaultUser.png");
                }

                storageReference = FirebaseStorage.Instance.GetReference($"users/{Fnametext.EditText.Text}_image");
                storageReference.PutBytes(imageArray);

                storageReference.GetDownloadUrl().AddOnSuccessListener(this);


                HashMap map = new HashMap();
                map.Put("fullname", Fnametext.EditText.Text);
                map.Put("email", emtext.EditText.Text);
                map.Put("password", passtext.EditText.Text);
                map.Put("profileimage", url);



                DocumentReference docRef = database.Collection("users").Document();

                docRef.Set(map);

                Toast.MakeText(this, "User Registered", ToastLength.Long).Show();
                FetchUserData();
            };


            login.Click += (sender, e) =>
            {
                string loginfname = Fnametext.EditText.Text.ToString();
                string loginemail = emtext.EditText.Text.ToString();
                string loginpass  = passtext.EditText.Text.ToString();

                //listOfUser=userservice.FetchUserData("user");

                //while (listOfUser.Count == 0)
                //{
                //}



                foreach (var item in listOfUser)
                {
                    Console.WriteLine("Fullname: " + item.Fullname);
                }
                foreach (var item in listOfUser)
                {
                    if (item.Fullname.Equals(loginfname) && item.Email.Equals(loginemail) && item.password.Equals(loginpass))
                    {
                        Intent secondpageintent = new Intent(this, typeof(SecondPageActivity));
                        secondpageintent.PutExtra("accepteduser", JsonConvert.SerializeObject(item));
                        StartActivity(secondpageintent);
                        return;
                    }
                }

                Toast.MakeText(this, "Invalid Credentials", ToastLength.Long).Show();
                return;
            };

            profimg.Click += (sender, e) =>
            {
                RequestPermissions(permissionGroup, 0);

                var trans = SupportFragmentManager.BeginTransaction();
                uploadimg = new UploadImageFragment();

                uploadimg.Show(trans, "profilepicmethod");

                uploadimg.uploadImage += (Bitmap bitmap, byte[] imgary) =>
                {
                    profimg.SetImageBitmap(bitmap);
                    imageArray = imgary;
                    uploadimg.Dismiss();
                };
            };



            googlelogin.Click += (sender, e) =>
            {
                var intent = Auth.GoogleSignInApi.GetSignInIntent(googleapiclient);
                StartActivityForResult(intent, 1);
            };
        }
예제 #29
0
        private void SubmitButton_Click(object sender, EventArgs e)
        {
            HashMap postMap = new HashMap();

            postMap.Put("author", AppDataHelper.GetFullname());
            postMap.Put("owner_id", AppDataHelper.GetFirebaseAuth().CurrentUser.Uid);

            postMap.Put("post_date", DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss tt"));
            postMap.Put("post_body", postEditText.Text);

            //this will return an instance of our firestore
            //this will also generate an id
            DocumentReference newPostRef = AppDataHelper.GetFirestore().Collection("posts").Document();
            //retrieve the document ID created
            string postKey = newPostRef.Id;

            postMap.Put("image_id", postKey);

            ShowProgressDialogue("Posting..");

            // Save post image to firebase storage
            StorageReference storageReference = null;

            //check if the filebytes is not null
            if (fileBytes != null)
            {
                //This is the location where our images will be uploaded in the Firebase Storage
                //"postImages/" + "photo" is the location + imagename
                storageReference = FirebaseStorage.Instance.GetReference("postImages/" + postKey);

                //this code will save our image file to firebase storage
                storageReference.PutBytes(fileBytes)
                .AddOnSuccessListener(taskCompletionListeners)
                .AddOnFailureListener(taskCompletionListeners);
            }
            taskCompletionListeners.Success += (obj, EventArgs args) =>
            {
                //check if storageReference is null
                if (storageReference != null)
                {
                    storageReference.DownloadUrl.AddOnSuccessListener(downloadUrlListener);
                }

                //to get hold of the URL
                downloadUrlListener.Success += (obj, args) =>
                {
                    string downloadUrl = args.Result.ToString();
                    postMap.Put("download_url", downloadUrl);

                    //Save post to Firebase Firestore
                    newPostRef.Set(postMap);

                    CloseProgressDialogue();
                    Finish();
                };
            };

            taskCompletionListeners.Failure += (obj, args) =>
            {
                Toast.MakeText(this, "Upload failed!", ToastLength.Short).Show();
                CloseProgressDialogue();
            };
        }
예제 #30
0
        //Dialog MyButton Click
        public void BuildDialog(object sender, int f)
        {
            MyButton b = (MyButton)sender;

            for (int i = 0; i < exes.Count; i++)
            {
                if (exes[i].name.Equals(b.Text))
                {
                    ab1 = exes[i];
                }
            }
            d1 = new Dialog(this);
            //if (exes.Contains)
            d1.SetCancelable(true);
            d1.SetTitle(ab1.name);
            d1.SetContentView(Resource.Layout.MyDialog);
            LinearLayout ll = d1.FindViewById <LinearLayout>(Resource.Id.AbcDEF);

            ll.Orientation = Orientation.Vertical;
            //
            LinearLayout DialogLayout = new LinearLayout(this);

            DialogLayout.LayoutParameters = vWrap;
            DialogLayout.Orientation      = Orientation.Vertical;
            DialogLayout.SetGravity(GravityFlags.CenterVertical);
            //Dialog TitleTV
            ExDialogTitle = new EditText(this);
            ExDialogTitle.SetBackgroundColor(Color.RoyalBlue);
            ExDialogTitle.Typeface = Typeface.CreateFromAsset(Assets, "Katanf.ttf");
            ExDialogTitle.SetTextColor(Color.DarkRed);
            ExDialogTitle.TextSize = 40;
            ExDialogTitle.Text     = ab1.name;
            DialogLayout.AddView(ExDialogTitle);
            //
            DialogExplenationTextView          = new EditText(this);
            DialogExplenationTextView.Text     = ab1.explenatiotn.ToString();
            DialogExplenationTextView.TextSize = 30;
            DialogExplenationTextView.SetTextColor(Color.Black);
            //
            if (f == 1)
            {
                if (!h)
                {
                    for (int i = 0; i < exes.Count; i++)
                    {
                        if (buttons[i].Text == b.Text)
                        {
                            b.Time = buttons[i].Time;

                            h = true;
                        }
                    }
                }
                dur = new EditText(this)
                {
                    Text             = b.Time.ToString(),
                    LayoutParameters = OneTwentyParams,
                    Typeface         = Typeface.CreateFromAsset(Assets, "Katanf.ttf"),
                    TextSize         = 35,
                };
                dur.SetBackgroundResource(Resource.Drawable.MyBackground);
                dur.InputType = InputTypes.ClassPhone;
                //
            }
            Save = new MyButton(this)
            {
                Text             = "Save",
                LayoutParameters = OneTwentyParams,
                TextSize         = 35,
                Typeface         = Typeface.CreateFromAsset(Assets, "Katanf.ttf"),
            };
            bool a = false;

            Save.Click += delegate
            {
                OAduration       -= b.Time;
                b.Time            = int.Parse(dur.Text);
                OAduration       += b.Time;
                OAdurationTV.Text = OAduration.ToString();
                a = true;
                if (OAduration <= 50 && OAduration >= 40)
                {
                    OAdurationTV.SetTextColor(Color.LawnGreen);
                }
                else if (OAduration > 50)
                {
                    OAdurationTV.SetTextColor(Color.Red);
                }
                else
                {
                    OAdurationTV.SetTextColor(Color.Black);
                }
                if (ExDialogTitle.Text != ab1.name)
                {
                    ab1.name = ExDialogTitle.Text;
                    a        = true;
                    Toasty.Info(this, "Happened2", 2, false).Show();
                }
                else if (DialogExplenationTextView.Text != ab1.explenatiotn)
                {
                    ab1.explenatiotn = DialogExplenationTextView.Text;
                    a = true;
                    Toasty.Info(this, "Happened3", 2, false).Show();
                }
                if (a == true)
                {
                    HashMap map = new HashMap();
                    map.Put("Explenation", ab1.explenatiotn);
                    map.Put("Name", ab1.name);
                    DocumentReference DocRef = database.Collection("Users").Document(admin.email).Collection("Exercises").Document(ab1.name);
                    DocRef.Set(map);
                }
            };
            ////Add BitMap
            //
            DialogLayout.AddView(DialogExplenationTextView);
            if (f == 1)
            {
                DialogLayout.AddView(dur);
            }
            DialogLayout.AddView(Save);
            ll.AddView(DialogLayout);
            d1.Show();
        }