public IActionResult Create(
     [Bind("StudName,StudGender,StudEmailAdd")]
     Studentdetails studentdetails)
 {
     if (ModelState.IsValid)
     {
         School.AddStudent(studentdetails.StudName, studentdetails.StudEmailAdd, studentdetails.StudGender);
         _toastNotification.AddSuccessToastMessage("Student created!");
         return(RedirectToAction(nameof(Index)));
     }
     return(View(studentdetails));
 }
        public IActionResult Edit(int id, [Bind("StudentId,StudName,StudDOB,StudGender,StudEmailAdd,StudAddress,StudphNum")] Studentdetails studentdetails)
        {
            if (id != studentdetails.StudentId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                School.Update(studentdetails);
                return(RedirectToAction(nameof(Index)));
            }
            return(View(studentdetails));
        }
예제 #3
0
        async Task GetStudents()
        {
            if (IsBusy)
            {
                return;
            }

            Exception error = null;

            try
            {
                IsBusy = true;

                var firebase = new FirebaseClient("https://studentappfirebase-667c5.firebaseio.com/");

                var Items = await firebase.Child("StudentDetails").OnceAsync <Student>();

                //await DisplayAlert("ok", Items.ToString(), "ok");

                //Load Student into list
                Studentdetails.Clear();

                foreach (var item in Items)
                {
                    Studentdetails.Add(item.Object);
                }
            }
            catch (Exception ex)
            {
                // Debug.WriteLine("Error: " + ex);
                error = ex;
                await Application.Current.MainPage.DisplayAlert("Error!", error.Message, "OK");
            }
            finally
            {
                IsBusy = false;
            }

            if (error != null)
            {
                await Application.Current.MainPage.DisplayAlert("Error!", error.Message, "OK");
            }
        }