예제 #1
0
 /// <summary>
 /// Delete specific parent
 /// </summary>
 /// <param name="pparent">the parent</param>
 public void DeleteParent(ApplicationUser pparent)
 {
     try
     {
         ApplicationUser   parent     = db.Users.Find(pparent.Id);
         CoursesRepository repository = new CoursesRepository();
         DeleteAllMessages(parent);
         DeleteAllPosts(parent);
         DeleteAllChildren(parent);
         db.Users.Remove(parent);
         db.SaveChanges();
     }
     catch (Exception e)
     {
         throw e;
     }
 }
예제 #2
0
 /// <summary>
 /// Deletes specific student
 /// </summary>
 /// <param name="pstudent">the student</param>
 public void DeleteStudent(ApplicationUser pstudent)
 {
     try
     {
         ApplicationUser   student    = db.Users.Find(pstudent.Id);
         CoursesRepository repository = new CoursesRepository();
         DeleteAllMessages(student);
         DeleteAllPosts(student);
         DeleteAsChildren(student);
         repository.DeleteCoursesEnrollments(student);
         db.Users.Remove(student);
         db.SaveChanges();
     }
     catch (Exception e)
     {
         throw e;
     }
 }
예제 #3
0
 /// <summary>
 /// Deletes specific teacher
 /// </summary>
 /// <param name="pteacher">the teacher</param>
 public void DeleteTeacher(ApplicationUser pteacher)
 {
     try
     {
         ApplicationUser   teacher    = db.Users.Find(pteacher.Id);
         CoursesRepository repository = new CoursesRepository();
         repository.DeleteAllCourses(teacher);
         DeleteAllMessages(teacher);
         DeleteAllPosts(teacher);
         var path = teacher.Path;
         Directory.Delete(path.ToString(), true);
         db.Users.Remove(teacher);
         db.SaveChanges();
     }
     catch (Exception e)
     {
         throw e;
     }
 }