コード例 #1
0
        private void _editProfessorButton_Click(object sender, EventArgs e)
        {
            errorHandlingFunctions newerror = new errorHandlingFunctions();
            var NameEdit  = FindViewById <EditText>(Resource.Id.professorsNameEdit);
            var PhoneEdit = FindViewById <EditText>(Resource.Id.professorsPhoneEdit);
            var EmailEdit = FindViewById <EditText>(Resource.Id.professorEmailEdit);


            foreach (Instructor item in thisProfList)
            {
                if (item.Id == profId)
                {
                    if (NameEdit.Text.Trim() != "")
                    {
                        item.Name = NameEdit.Text;
                    }
                    else
                    {
                        Toast.MakeText(this, "Please add a valid name", ToastLength.Short).Show(); return;
                    }
                    if (PhoneEdit.Text.Length == 10)
                    {
                        item.PhoneNumber = PhoneEdit.Text;
                    }
                    else
                    {
                        Toast.MakeText(this, "Please add a 10 digit number, including area code. No spaces or symbols", ToastLength.Short).Show(); return;
                    }
                    if (newerror.validEmail(EmailEdit.Text) == true)
                    {
                        item.Email = EmailEdit.Text;
                    }
                    else
                    {
                        Toast.MakeText(this, "Please add a valid email", ToastLength.Short).Show(); return;
                    }

                    _professorAdapter.editList(item);
                    thisRepository.SaveEditedProf(thisProfList);
                    _professorAdapter.NotifyDataSetChanged();
                }
            }
        }