private void AddButton_Click(object sender, EventArgs e)
        {
            string name, phone, email, city, country;

            name    = newUserName.EditText.Text;
            phone   = newPhoneNumber.EditText.Text;
            email   = newEmail.EditText.Text;
            city    = newCity.EditText.Text;
            country = newCountry.EditText.Text;

            if (name.Length < 5)
            {
                Toast.MakeText(Activity, "Please provide a valid name.", ToastLength.Short).Show();
                return;
            }
            else if (!email.Contains("@"))
            {
                Toast.MakeText(Activity, "Please provide a valid email address.", ToastLength.Short).Show();
                return;
            }
            else if (phone.Length < 10)
            {
                Toast.MakeText(Activity, "Please provide a valid phone number.", ToastLength.Short).Show();
                return;
            }
            else if (city.Length < 2)
            {
                Toast.MakeText(Activity, "Please provide a valid city.", ToastLength.Short).Show();
                return;
            }
            else if (country.Length < 2)
            {
                Toast.MakeText(Activity, "Please provide a valid country.", ToastLength.Short).Show();
                return;
            }
            else if (selectedBloodType.Length < 2)
            {
                Toast.MakeText(Activity, "Please provide a valid blood type.", ToastLength.Short).Show();
                return;
            }

            Donor newDonor = new Donor();

            newDonor.Fullname   = name;
            newDonor.Phone      = phone;
            newDonor.Email      = email;
            newDonor.City       = city;
            newDonor.Country    = country;
            newDonor.BloodGroup = selectedBloodType;

            OnDonorRegistered?.Invoke(this, new DonorDetailsEventArgs {
                Donor = newDonor
            });
        }
예제 #2
0
        private void SaveButton_Click(object sender, EventArgs e)
        {
            string fullname, email, phone, city, country;

            fullname = fullnameText.EditText.Text;
            email    = emailText.EditText.Text;
            phone    = phoneText.EditText.Text;
            city     = cityText.EditText.Text;
            country  = countryText.EditText.Text;

            if (fullname.Length < 5)
            {
                Toast.MakeText(Activity, "Please provide a valid name", ToastLength.Short).Show();
                return;
            }
            else if (!email.Contains("@"))
            {
                Toast.MakeText(Activity, "Please provide a valid email address", ToastLength.Short).Show();
                return;
            }
            else if (phone.Length < 10)
            {
                Toast.MakeText(Activity, "Please provide a valid phone number", ToastLength.Short).Show();
                return;
            }
            else if (city.Length < 2)
            {
                Toast.MakeText(Activity, "Please provide a valid city", ToastLength.Short).Show();
                return;
            }
            else if (country.Length < 2)
            {
                Toast.MakeText(Activity, "Please provide a valid country", ToastLength.Short).Show();
                return;
            }
            else if (selectedBloodGroup.Length < 2)
            {
                Toast.MakeText(Activity, "Please select a blood group", ToastLength.Short).Show();
                return;
            }

            Donor donor = new Donor();

            donor.Fullname   = fullname;
            donor.Email      = email;
            donor.Phone      = phone;
            donor.City       = city;
            donor.Country    = country;
            donor.BloodGroup = selectedBloodGroup;

            OnDonorRegistered?.Invoke(this, new DonorDetailsEventArgs {
                Donor = donor
            });
        }
예제 #3
0
        private void SaveButton_Click(object sender, EventArgs e)
        {
            string fullname, email, phone, city, country, latitude, longitude;

            fullname  = fullnameText.EditText.Text;
            email     = emailText.EditText.Text;
            phone     = phoneText.EditText.Text;
            city      = cityText.EditText.Text;
            country   = countryText.EditText.Text;
            latitude  = latitudeText.EditText.Text;
            longitude = longitudeText.EditText.Text;
            latitude  = latitude.Replace(".", ",");
            longitude = longitude.Replace(".", ",");

            if (fullname.Length < 5)
            {
                Toast.MakeText(Activity, "Please provide a valid name", ToastLength.Short).Show();
                return;
            }
            else if (!email.Contains("@"))
            {
                Toast.MakeText(Activity, "Please provide a valid email address", ToastLength.Short).Show();
                return;
            }
            else if (phone.Length < 10)
            {
                Toast.MakeText(Activity, "Please provide a valid phone number", ToastLength.Short).Show();
                return;
            }
            else if (city.Length < 2)
            {
                Toast.MakeText(Activity, "Please provide a valid city", ToastLength.Short).Show();
                return;
            }
            else if (country.Length < 2)
            {
                Toast.MakeText(Activity, "Please provide a valid country", ToastLength.Short).Show();
                return;
            }
            else if (selectedBloodGroup.Length < 2)
            {
                Toast.MakeText(Activity, "Please select a blood group", ToastLength.Short).Show();
                return;
            }
            else if (latitude.Length < 1)
            {
                Toast.MakeText(Activity, "Please provide a valid latitude", ToastLength.Short).Show();
                return;
            }
            else if (longitude.Length < 1)
            {
                Toast.MakeText(Activity, "Please provide a valid longitude", ToastLength.Short).Show();
                return;
            }
            Console.WriteLine(latitude);
            Console.WriteLine(Convert.ToDouble(latitude));
            var   totalDonors = conn.Table <Donor>().ToList().Count;
            Donor donor       = new Donor(totalDonors, fullname, phone, email, city, country, selectedBloodGroup, Convert.ToDouble(latitude), Convert.ToDouble(longitude));

            conn.Insert(donor);
            OnDonorRegistered?.Invoke(this, new DonorDetailsEventArgs {
                Donor = donor
            });
        }