Ejemplo n.º 1
0
 // Initialize Subject and add in  CurrentselectedSubject
 public void InitializeSubject(string selectedSubjectName)
 {
     using (ClassbookEntities context = new ClassbookEntities())
     {
         CurrentselectedSubject = context.Subjects.FirstOrDefault(a => a.Name == selectedSubjectName);
     }
 }
Ejemplo n.º 2
0
 // 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;
     }
 }
Ejemplo n.º 4
0
 // Add all visible subject
 public List <string> SubjectsToInsert()
 {
     using (ClassbookEntities context = new ClassbookEntities())
     {
         return(StudentSubjects.Select(w => w.Name).ToList());
     }
 }
Ejemplo n.º 5
0
        // 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>());
     }
 }
Ejemplo n.º 7
0
 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);
     }
 }
Ejemplo n.º 8
0
 public void SetCurrentClassTeacherId(string teacherName)
 {
     SetTeacherId();
     using (ClassbookEntities context = new ClassbookEntities())
     {
         CurrentClassTeacherId = context.Teachers.ToList().FirstOrDefault(w => w.FirstName + ' ' + w.LastName == teacherName).TeacherId;
     }
 }
Ejemplo n.º 9
0
 public string StudentEGNFromParent(string parentEGN)
 {
     using (ClassbookEntities context = new ClassbookEntities())
     {
         StudentEGNFromParentProp = context.Parents.First(w => w.PersonalNumber == parentEGN).Student.PersonalNumber;
     }
     return(StudentEGNFromParentProp);
 }
Ejemplo n.º 10
0
 public string EgnPassSetForParent(string EGN)
 {
     using (ClassbookEntities context = new ClassbookEntities())
     {
         Parent parent = context.Parents.FirstOrDefault(c => c.PersonalNumber == EGN);
         return(parent.PersonalNumber);
     }
 }
Ejemplo n.º 11
0
 public string EgnPassSetForTeacher(string EGN)
 {
     using (ClassbookEntities context = new ClassbookEntities())
     {
         Teacher teacher = context.Teachers.FirstOrDefault(c => c.PersonalNumber == EGN);
         return(teacher.PersonalNumber);
     }
 }
Ejemplo n.º 12
0
        /// <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;
     }
 }
Ejemplo n.º 14
0
 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);
 }
Ejemplo n.º 15
0
 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);
     }
 }
Ejemplo n.º 16
0
 // 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);
     }
 }
Ejemplo n.º 17
0
 public void CommitChangedSubject()
 {
     PushCurrentSubject();
     using (ClassbookEntities context = new ClassbookEntities())
     {
         context.Subjects.Add(currentSubject);
         context.SaveChanges();
     }
 }
Ejemplo n.º 18
0
 //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();
     }
 }
Ejemplo n.º 19
0
 // 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;
     }
 }
Ejemplo n.º 20
0
 public void CommitChangedCurrentClassed()
 {
     PushClass();
     using (ClassbookEntities context = new ClassbookEntities())
     {
         currentClass.Teacher = context.Teachers.FirstOrDefault(w => w.TeacherId == CurrentClassTeacherId);
         context.Classes.Add(currentClass);
         context.SaveChanges();
     }
 }
Ejemplo n.º 21
0
 // 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;
     }
 }
Ejemplo n.º 22
0
 // 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();
     }
 }
Ejemplo n.º 25
0
 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);
         }
     }
 }
Ejemplo n.º 30
0
 public bool ParentExists(string EGN)
 {
     using (ClassbookEntities context = new ClassbookEntities())
     {
         if (context.Parents.Any(c => c.PersonalNumber == EGN))
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
 }