/// <summary> /// Adds a teacher to the database /// </summary> /// <param name="teacher">The teacher-object to be added</param> /// <exception cref="DuplicateUserException"></exception> public void AddTeacher(Teacher teacher) { List<Teacher> existing = (from t in entities.Teachers where t.UserName == teacher.UserName select t).ToList(); if (existing.Count > 0) { teacher.UserName += existing.Count + 1; } //if (!UserExists(teacher.UserName)) //{ entities.AddToTeachers(teacher); entities.SaveChanges(); //} //else { // throw new DuplicateUserException("User \"" + teacher.UserName + "\" already exists!"); //} }
public static MemoryStream GeneratePDF(Teacher teacher, SchoolClass schoolClass, string schoolYear) { Document document = new Document(); MemoryStream stream = new MemoryStream(); PdfWriter writer = PdfWriter.GetInstance(document, stream); writer.CloseStream = false; document.Open(); document.AddCreationDate(); document.AddAuthor("VaKEGrade"); document.AddTitle("Certificate"); foreach (Pupil pupil in teacher.PrimaryClasses.First().Pupils.OrderBy(x => x.LastName).ToList()) { CertificateGenerator.GenerateCertificate(pupil, schoolClass, schoolYear, ref document); } document.Close(); stream.Seek(0, SeekOrigin.Begin); return stream; }
public bool IsUserClassTeacher(Teacher teacher) { return teacher.PrimaryClasses.Count > 0 || teacher.SecondaryClasses.Count > 0; }
//public SchoolClass GetClassOfClassTeacher(Teacher teacher) { //} public IEnumerable<SchoolClass> GetClassesOfTeacher(Teacher teacher) { return (from tsa in teacher.TeacherSubjectAssignments select tsa.SchoolClass).Distinct(); }
public void AssignSubject(Teacher teacher, Subject subject, SchoolClass schoolClass) { entities.AddToTeacherSubjectAssignments(new TeacherSubjectAssignment() { Teacher = teacher, Subject = subject, SchoolClass = schoolClass}); entities.SaveChanges(); }
public void AssignSchoolClass(Teacher teacher, SchoolClass schoolClass) { if (teacher.PrimaryClasses.Count > 0) throw new AlreadyAssignedException(teacher.PrimaryClasses.First(), teacher); teacher.PrimaryClasses.Add(schoolClass); entities.SaveChanges(); }
public void GenerateTeachers() { Random random; Teacher teacher; for (int i = 0; i < 20; i++) { random = new Random(); teacher = new Teacher(); if (random.Next(0, 2) == 0) { teacher.FirstName = mFirstNames[random.Next(0, mFirstNames.Length)]; } else { teacher.FirstName = wFirstNames[random.Next(0, wFirstNames.Length)]; } teacher.LastName = lastNames[random.Next(0, lastNames.Length)]; teacher.UserName = teacher.FirstName[0] + teacher.LastName; teacher.Password = "******"; repository.AddTeacher(teacher); } }
/// <summary> /// Deprecated Method for adding a new object to the Teachers EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToTeachers(Teacher teacher) { base.AddObject("Teachers", teacher); }
/// <summary> /// Create a new Teacher object. /// </summary> /// <param name="id">Initial value of the ID property.</param> /// <param name="firstName">Initial value of the FirstName property.</param> /// <param name="lastName">Initial value of the LastName property.</param> /// <param name="userName">Initial value of the UserName property.</param> /// <param name="password">Initial value of the Password property.</param> public static Teacher CreateTeacher(global::System.Int32 id, global::System.String firstName, global::System.String lastName, global::System.String userName, global::System.String password) { Teacher teacher = new Teacher(); teacher.ID = id; teacher.FirstName = firstName; teacher.LastName = lastName; teacher.UserName = userName; teacher.Password = password; return teacher; }