Пример #1
0
 /// <summary>
 /// We get the picked student and sends it to be deleted from DB
 /// </summary>
 /// <param name="student"></param>
 public void DeleteStudent(Student student)
 {
     ApiHelper.Instance.DeleteStudent(student.StudentId);
     foreach (Student s in AllStudents.ToList())
     {
         if (s.StudentId == student.StudentId)
         {
             AllStudents.Remove(s);
             AllUsers.Remove(s);
         }
     }
 }
        public void RemoveStudent()
        {
            Console.WriteLine("Deleting a student");
            Console.Write("Type his/her name : ");
            string name = Console.ReadLine();

            foreach (Student student in AllStudents)
            {
                if (student.Name == name)
                {
                    AllStudents.Remove(student);
                    Console.WriteLine($"{student.Name} has been removed");
                    break;
                }
            }
        }
Пример #3
0
        private void RemoveRecord()
        {
            if (MessageBox.Show("Are sure to delete this student ? ", "Confirm", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.No)
            {
                return;
            }
            SchoolObjContext context = new SchoolObjContext();
            dynamic          item    = CurrentItem;

            EntityDatabase.DomainClasses.Student SelectedStudent = CurrentItem.Student;
            EntityDatabase.DomainClasses.Student obj             = context.Students.Where(s => s.StudentId == SelectedStudent.StudentId).FirstOrDefault();
            if (obj == null)
            {
                return;
            }
            context.Students.Remove(obj);
            context.SaveChanges();

            AllStudents.Remove(CurrentItem);
        }