Advertisement
Guest User

Untitled

a guest
Dec 17th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.74 KB | None | 0 0
  1. interface IDBcontext
  2. {
  3.     List<Student> GetAllStudents();
  4.     List<Klass> GetAllKlasses();
  5.  
  6.     Student FindStudentById(int studentID);
  7.     void RemoveStudent(Student);
  8.     void SaveStudent(Student);
  9.     // Other methods if needed
  10.  
  11.     // The same for klass....
  12.     Klass FindKlassById(int klassID);
  13. }
  14.  
  15. class XmlDBContext : IDBContext
  16. {
  17.     XmlDBContext(string filename) {}
  18. }
  19.  
  20. class Program
  21. {
  22.     IDBContext dbContext;
  23.     IWindowOperations ops;
  24.  
  25.  
  26.     public static void Main(string[] args)
  27.     {
  28.         dbContext = new XmlDBContext("file.xml");
  29.  
  30.         // ...
  31.  
  32.         var student = dbContext.findStudentById(studentId);
  33.         if (student == null)
  34.         {
  35.             ops.Error("Student doesn't exist");
  36.         }
  37.         else
  38.         {
  39.             ops.LoadStudentToEdit(student);
  40.             dbContext.Save(student);
  41.         }
  42.     }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement