from source.data.dataAccessDictionary.dataProviderStudent import DataProviderStudent
from source.domain.student import Student

dataProviderStudent = DataProviderStudent()
# Student 1
student1 = Student()
student1.setStudentId(1)
student1.setName("Ali")
student1.setPassword("12345")
student1.setContactNumber("5454444444")
student1.setAddress("142 street")
student1.setEmail("*****@*****.**")

# Student 2
student2 = Student()
student2.setStudentId(2)
student2.setName("Mehmet")
student2.setPassword("54654756")
student2.setContactNumber("543786786556")
student2.setAddress("222 Street")
student2.setEmail("*****@*****.**")

# Student 3
student3 = Student()
student3.setStudentId(3)
student3.setName("Mesut")
student3.setPassword("543423654756")
student3.setContactNumber("1111")
student3.setAddress("2122 Street")
student3.setEmail("*****@*****.**")
Beispiel #2
0
 def update(self, student):
     global studentList
     for studentId, studentInfo in studentList.items():
         if studentId == student.getStudentId():
             currentStudent = Student()
             currentStudent.setStudentId(student.getStudentId())
             currentStudent.setName(student.getName())
             currentStudent.setEmail(student.getEmail())
             currentStudent.setAddress(student.getAddress())
             currentStudent.setContactNumber(student.getContactNumber())
             currentStudent.setPassword(student.getPassword())
             studentList[studentId] = currentStudent
             return True
     return False
Beispiel #3
0
 def getById(self, id):
     global studentList
     for studentId, studentInfo in studentList.items():
         if studentId == id:
             currentStudent = Student()
             currentStudent.setStudentId(studentInfo.getStudentId())
             currentStudent.setName(studentInfo.getName())
             currentStudent.setEmail(studentInfo.getEmail())
             currentStudent.setAddress(studentInfo.getAddress())
             currentStudent.setContactNumber(studentInfo.getContactNumber())
             currentStudent.setPassword(studentInfo.getPassword())
             # currentStudent = studentInfo
             return currentStudent
     return False
 def getById(self, id):
     global studentList
     with open(connectionString, "r") as studentListFile:
         studentListFromFile = dict(json.load(studentListFile))
         for studentId, studentInfo in studentListFromFile.items():
             if studentId == id:
                 currentInsertedStudent = json.loads(studentInfo)
                 currentStudent = Student()
                 currentStudent.setStudentId(
                     currentInsertedStudent["studentId"])
                 currentStudent.setName(currentInsertedStudent["name"])
                 currentStudent.setEmail(currentInsertedStudent["email"])
                 currentStudent.setAddress(
                     currentInsertedStudent["address"])
                 currentStudent.setContactNumber(
                     currentInsertedStudent["contactNumber"])
                 currentStudent.setPassword(
                     currentInsertedStudent["password"])
                 return currentStudent
         return False
 def getList(self):
     global studentList
     studentList.clear()
     try:
         with open(connectionString, "r") as studentListFile:
             studentListFromFile = dict(json.load(studentListFile))
             for studentId, studentInfo in studentListFromFile.items():
                 currentInsertedStudent = json.loads(studentInfo)
                 currentStudent = Student()
                 currentStudent.setStudentId(
                     currentInsertedStudent["studentId"])
                 currentStudent.setName(currentInsertedStudent["name"])
                 currentStudent.setEmail(currentInsertedStudent["email"])
                 currentStudent.setAddress(
                     currentInsertedStudent["address"])
                 currentStudent.setContactNumber(
                     currentInsertedStudent["contactNumber"])
                 currentStudent.setPassword(
                     currentInsertedStudent["password"])
                 studentList[currentStudent.getStudentId(
                 )] = currentStudent.toJson()
                 # result = 1 / 0
             if studentList.items() == 0:
                 raise ValueError(
                     "Dosya içerisinde herhangi kayıt bulunamadı.")
             return studentList
     except FileNotFoundError as fileNotFoundError:
         return fileNotFoundError
     except ValueError as valueError:
         return valueError
     except ZeroDivisionError as zeroDivisionError:
         return zeroDivisionError
     except Exception as ex:
         return ex
 def update(self, student):
     global studentList
     for studentId, studentInfo in studentList.items():
         if studentId == student.getStudentId():
             currentStudent = Student()
             currentStudent.setStudentId(student.getStudentId())
             currentStudent.setName(student.getName())
             currentStudent.setPassword(student.getPassword())
             currentStudent.setContactNumber(student.getContactNumber())
             currentStudent.setEmail(student.getEmail())
             currentStudent.setAddress(student.getAddress())
             studentList[
                 currentStudent.getStudentId()] = currentStudent.toJson()
             with open(connectionString, "w") as studentListFile:
                 json.dump(studentList, studentListFile)
             return True
     return False
Beispiel #7
0
 def update(self, studentViewModelUpdate):
     student = Student()
     student.setStudentId(studentViewModelUpdate.getStudentId())
     student.setName(studentViewModelUpdate.getName())
     student.setEmail(studentViewModelUpdate.getEmail())
     student.setContactNumber(studentViewModelUpdate.getContactNumber())
     student.setPassword(studentViewModelUpdate.getPassword())
     student.setAddress(studentViewModelUpdate.getAddress())
     return self.dataProviderStudent.update(student)
Beispiel #8
0
 def insert(self, studentViewModelInsertion):
     student = Student()
     student.setStudentId(studentViewModelInsertion.getStudentId())
     student.setName(studentViewModelInsertion.getName())
     student.setEmail(studentViewModelInsertion.getEmail())
     student.setContactNumber(studentViewModelInsertion.getContactNumber())
     student.setPassword(studentViewModelInsertion.getPassword())
     student.setAddress(studentViewModelInsertion.getAddress())
     return self.dataProviderStudent.insert(
         student)  # result of insert method TRUE or FALSE