public void Execute(StudentRequest student) { Student entity = StudentAdapter.GetEntity(student); entity.ListCources = student.ListCourses.Select(x => _courseRepository.GetByID(x)).ToList(); try { _studentRepository.AddNew(entity); } catch (Exception exc) { throw new StudentException("Error while create student!", exc); } }
private void ZapiszButtonClick(object sender, RoutedEventArgs e) { string name = this.Name.Text; string surname = this.Surname.Text; bool gender = this.checkGender.IsChecked.Value ? true : false; if (name != "" && surname != "") { IClassRepository claassRepository = LibrusFactory.CreateClassRepository(); ClassEntity clazz = claassRepository.GetById(this.value); StudentEntity student = new StudentEntity(name, surname, clazz, gender); IStudentRepository studentRepository = LibrusFactory.CreateStudentRepository(); studentRepository.AddNew(student); NavigationService.GoBack(); } }
public static void InsertTestData() { if (!DataContext.DatabaseExists()) { DataContext.CreateDatabase(); var fakeManager = GetFakeManager(); var manager = GetManager(); var classes = fakeManager.GetAllClasses(); foreach (var clazz in classes) { classRepository.AddNew(new ClassEntity(clazz.Id)); } var subjects = fakeManager.GetAllSubjects(); foreach (var subject in subjects) { subjectRepository.AddNew(new SubjectEntity(subject.Id, subject.Name)); } var students = fakeManager.GetAllStudents(); foreach (var student in students) { studentRepository.AddNew(new StudentEntity(student.Name, student.Surname, classRepository.GetById(student.Class.Id), student.Gender)); } var timetables = fakeManager.GetAllTimetables(); foreach (var timetable in timetables) { timeTableRepository.AddNew(new TimeTableEntity(timetable.Day, classRepository.GetById(timetable.Class.Id), subjectRepository.GetById(timetable.Subject.Id))); } var presences = fakeManager.GetAllPresences(); foreach (var presence in presences) { presenceRepository.AddNew(new PresenceEntity(studentRepository.GetById(presence.Student.StudentId), subjectRepository.GetById(presence.Subject.Id), presence.Date.Date, presence.Present)); } } }