private async Task ExeucteAddTeacherAsync(object parameter) { if (String.IsNullOrWhiteSpace(FirstName) || String.IsNullOrWhiteSpace(LastName) || String.IsNullOrWhiteSpace(Login) || String.IsNullOrWhiteSpace(Email)) { MessageBoxHelper.ShowErrorMessageBox("Wypełnij wszystkie pola."); return; } try { await _longRunningOperationHelper.ProceedLongRunningOperationAsync(async() => { string password = _loginService.GeneratePassword(); string hashedPassword = _loginService.HashPassword(password); long id = _uniqueIDGenerator.GetNextIdForUser(); var teacher = new Teacher(id) { FirstName = FirstName, LastName = LastName, Login = Login, Email = Email, Password = password, HashedPassword = hashedPassword }; await _usersRepository.InsertOrReplaceAsync(teacher); await _mailingService.SendEmailWithLoginAndPasswordAsync(teacher, Administrator); AllTeachers.Add(teacher); OnPropertyChanged(nameof(AllTeachers)); }); MessageBoxHelper.ShowMessageBox("Nauczyciel dodany do systemu."); ClearAllFields(); } catch (TableException ex) { MessageBoxHelper.ShowErrorMessageBox(ex.Message); } }
public Teacher() { AllTeachers.Add(this); }
public void RegisterTeacher() { Console.WriteLine("Registering of a new teacher"); Console.Write("Type his/her name : "); string name = Console.ReadLine(); Console.Write("Type his/her adress : "); string adress = Console.ReadLine(); Console.Write("Type his/her phone number : "); string phoneNumber = Console.ReadLine(); Console.Write("Type his/her email : "); string email = Console.ReadLine(); Console.Write("Type his/her password : "******"You want to register a teacher for a course, which branch is concerned ?"); string branche = Console.ReadLine(); Console.WriteLine("What's the name of the course ?"); string nameCourse = Console.ReadLine(); int brancheNumber = -1; switch (branche) { case "Business": brancheNumber = 0; break; case "Ingeneering": brancheNumber = 1; break; case "Literature": brancheNumber = 2; break; } for (int i = 0; i < AllCourses[brancheNumber].Count; i++) { if (nameCourse == AllCourses[brancheNumber][i].NameCourse) { teacher.Course = AllCourses[brancheNumber][i]; Console.WriteLine($"{teacher.Name} has been registered for the course {teacher.Course.NameCourse}\n"); break; } } teacher.GroupStudents.Clear(); foreach (Student student in AllStudents) { if (student.Branche.BrancheName == Branches.Keys[brancheNumber]) { teacher.GroupStudents.Add(student); } } }