// Initialize Subject and add in CurrentselectedSubject public void InitializeSubject(string selectedSubjectName) { using (ClassbookEntities context = new ClassbookEntities()) { CurrentselectedSubject = context.Subjects.FirstOrDefault(a => a.Name == selectedSubjectName); } }
// Set mark teacher id in NewmarkTeacherID public void SetMarkTeacherID(string egnPass) { using (ClassbookEntities context = new ClassbookEntities()) { NewmarkTeacherID = context.Teachers.FirstOrDefault(w => w.PersonalNumber == egnPass).TeacherId; } }
// Set Class string public void SetClasses(string Class) { using (ClassbookEntities context = new ClassbookEntities()) { selectedClassId = context.Classes.FirstOrDefault(w => w.Grade + w.Letter == Class).ClassId; } }
// Add all visible subject public List <string> SubjectsToInsert() { using (ClassbookEntities context = new ClassbookEntities()) { return(StudentSubjects.Select(w => w.Name).ToList()); } }
// Return all marks and teacher name public List <string> StudentMarksToInsert() { PushAllMarks(); using (ClassbookEntities context = new ClassbookEntities()) { List <Mark> allStudentMarksForSubject = new List <Mark>(); var currentStudent = CurrentStudent; // Fills allStudentMarksForSubject context.Marks.ToList().ForEach(w => { if (w.SubjectId == CurrentselectedSubject.SubjectId && CurrentStudent.StudentId == w.StudentId) { allStudentMarksForSubject.Add(w); } }); List <string> SelectedMarksList = new List <string>(); CurrentAvarageMark = Math.Round(allStudentMarksForSubject.Select(w => w.Number).ToList().Average(), 2).ToString(); // Converts allStudentMarksForSubject's items into a string and puts them into SelectedMarksList for (int i = 0; i < allStudentMarksForSubject.Count(); i++) { SelectedMarksList.Add(allStudentMarksForSubject[i].Description + ' ' + allStudentMarksForSubject[i].Number + " Teacher: " + allStudentMarksForSubject[i].Teacher.FirstName + ' ' + allStudentMarksForSubject[i].Teacher.MiddleName + ' ' + allStudentMarksForSubject[i].Teacher.LastName + " Date: " + allStudentMarksForSubject[i].Date.ToShortDateString()); } return(SelectedMarksList); } }
public List <string> GetAllSubjects() { using (ClassbookEntities context = new ClassbookEntities()) { return(context.Subjects.Select(c => c.Name).ToList <string>()); } }
public List <string> LoadClasses() { using (ClassbookEntities context = new ClassbookEntities()) { List <string> classes = context.Classes.OrderBy(w => w.Grade).ThenBy(w => w.Letter).Select(w => w.Grade + w.Letter).ToList(); return(classes); } }
public void SetCurrentClassTeacherId(string teacherName) { SetTeacherId(); using (ClassbookEntities context = new ClassbookEntities()) { CurrentClassTeacherId = context.Teachers.ToList().FirstOrDefault(w => w.FirstName + ' ' + w.LastName == teacherName).TeacherId; } }
public string StudentEGNFromParent(string parentEGN) { using (ClassbookEntities context = new ClassbookEntities()) { StudentEGNFromParentProp = context.Parents.First(w => w.PersonalNumber == parentEGN).Student.PersonalNumber; } return(StudentEGNFromParentProp); }
public string EgnPassSetForParent(string EGN) { using (ClassbookEntities context = new ClassbookEntities()) { Parent parent = context.Parents.FirstOrDefault(c => c.PersonalNumber == EGN); return(parent.PersonalNumber); } }
public string EgnPassSetForTeacher(string EGN) { using (ClassbookEntities context = new ClassbookEntities()) { Teacher teacher = context.Teachers.FirstOrDefault(c => c.PersonalNumber == EGN); return(teacher.PersonalNumber); } }
/// <summary> /// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /// </summary> public void SetExtendedPermissionsTrue(string testString) { using (ClassbookEntities context = new ClassbookEntities()) { context.Teachers.ToList().FirstOrDefault(w => w.FirstName + ' ' + w.LastName == testString).ExtendedPermissions = true; context.SaveChanges(); } }
public void SetSubject(string SubjectText) { using (ClassbookEntities context = new ClassbookEntities()) { string selectedSubject = SubjectText; // subjectCombBox.SelectedItem.ToString(); //.SelectedValue.ToString(); subject = context.Subjects.FirstOrDefault(w => w.Name == selectedSubject).Name; } }
public string SetFirstLastName(string egnParentPass) { using (ClassbookEntities context = new ClassbookEntities()) { Parent parent = context.Parents.First(w => w.PersonalNumber == egnParentPass); ParentFirstLastName = parent.FirstName + ' ' + parent.LastName; } return(ParentFirstLastName); }
public string SetFirstLastName(string egnPass) { using (ClassbookEntities context = new ClassbookEntities()) { string firstName = context.Students.FirstOrDefault(w => w.PersonalNumber == egnPass).FirstName; string lastName = context.Students.FirstOrDefault(w => w.PersonalNumber == egnPass).LastName; return(firstName + " " + lastName); } }
// Add HeadTeachersIds public List <int> HeadTeacherIds() { using (ClassbookEntities context = new ClassbookEntities()) { List <int> headTeacherIds = new List <int>(); context.Classes.ToList().ForEach(w => headTeacherIds.Add(w.HeadTeacherId)); return(headTeacherIds); } }
public void CommitChangedSubject() { PushCurrentSubject(); using (ClassbookEntities context = new ClassbookEntities()) { context.Subjects.Add(currentSubject); context.SaveChanges(); } }
//ADD UNIT TESTS public void DeleteMark(string markId) { using (ClassbookEntities context = new ClassbookEntities()) { Mark mark = context.Marks.FirstOrDefault(w => w.MarkId.ToString() == markId); context.Marks.Remove(mark); context.SaveChanges(); } }
// Set student Id in NewmarkStudentID public void SetStudentId(string SelectedStudent) { using (ClassbookEntities context = new ClassbookEntities()) { Student student = new Student(); List <Student> students = context.Students.ToList(); student = students.First(w => (w.FirstName + ' ' + w.MiddleName + ' ' + w.LastName) == SelectedStudent); NewmarkStudentID = student.StudentId; } }
public void CommitChangedCurrentClassed() { PushClass(); using (ClassbookEntities context = new ClassbookEntities()) { currentClass.Teacher = context.Teachers.FirstOrDefault(w => w.TeacherId == CurrentClassTeacherId); context.Classes.Add(currentClass); context.SaveChanges(); } }
// Initialize Student in CurrentStudent public void InitializeStudent(string egnPass) { using (ClassbookEntities context = new ClassbookEntities()) { CurrentStudent = context.Students.First(w => w.PersonalNumber == egnPass); StudentSubjects = CurrentStudent.Marks.Select(c => c.Subject).Distinct().ToList(); StudentClassId = CurrentStudent.Class.ClassId; HeadTeacher = CurrentStudent.Class.Teacher; StudentId = CurrentStudent.StudentId; } }
// Select Student public List <string> SelectStudent(string SelectedClass) { using (ClassbookEntities context = new ClassbookEntities()) { return(context.Students.Where(w => w.Class == context.Classes .FirstOrDefault(c => c.Grade + c.Letter == SelectedClass)) .ToList <Student>() .Select(z => z.FirstName + ' ' + z.MiddleName + ' ' + z.LastName) .ToList <string>()); } }
// Commit public void CommitChanged() { PushStudent(); PushStudentContactInfo(); using (ClassbookEntities context = new ClassbookEntities()) { student.StudentContactInfoes.Add(studentContactInfo); student.Class = context.Classes.FirstOrDefault(w => w.ClassId == selectedClassId); context.Students.Add(student); context.SaveChanges(); } }
// Last Commit Changed public void CommitChanged() { PushTeacher(); PushTeacherContactInfo(); using (ClassbookEntities context = new ClassbookEntities()) { teacher.TeacherContactInfoes.Add(teacherContactInfo); teacher.Subject = context.Subjects.FirstOrDefault(w => w.Name == subject); context.Teachers.Add(teacher); context.SaveChanges(); } }
public void CommitChangedMark() { PushClass(); PushMark(); PushIds(); using (ClassbookEntities context = new ClassbookEntities()) { newmark.Student = context.Students.FirstOrDefault(w => w.StudentId == newmarkStudentID); newmark.Teacher = context.Teachers.FirstOrDefault(w => w.TeacherId == newmarkTeacherID); newmark.Subject = context.Subjects.FirstOrDefault(w => w.SubjectId == newmarkSubjectID); context.Marks.Add(newmark); context.SaveChanges(); } }
// Check class is valid public bool IsValidClass(string Class) { using (ClassbookEntities context = new ClassbookEntities()) { if (context.Classes.Any(w => w.Grade + w.Letter == Class)) { return(true); } else { return(false); } } }
// Check EGN Exists public bool CheckEGNExists(string EGN) { using (ClassbookEntities context = new ClassbookEntities()) { if (context.Students.Any(w => w.PersonalNumber == EGN)) { return(true); } else { return(false); } } }
// Check Phone exists public bool CheckPhoneExists(string PhoneNumber) { using (ClassbookEntities context = new ClassbookEntities()) { if (context.StudentContactInfoes.Any(w => w.PhoneNumber == PhoneNumber)) { return(true); } else { return(false); } } }
// Check email exists public bool CheckEmailExists(string Email) { using (ClassbookEntities context = new ClassbookEntities()) { if (!context.StudentContactInfoes.Any(w => w.Email == Email)) { return(true); } else { return(false); } } }
public bool ParentExists(string EGN) { using (ClassbookEntities context = new ClassbookEntities()) { if (context.Parents.Any(c => c.PersonalNumber == EGN)) { return(true); } else { return(false); } } }