Exemple #1
0
        public int GetIdOfTeacher(Teachers entityToGetId)
        {
            ITeachersRepository repo = new TeachersRepository(getEntities());

            Entities.Teachers entityToGetId2 = Mapper.Map <Teachers, Entities.Teachers>(entityToGetId);
            return(repo.GetTeacherId(entityToGetId2));
        }
Exemple #2
0
        public HttpResponseMessage DisplaySingleTeacherInfo(int id)
        {
            var teacherInfo       = new TeachersRepository();
            var singleTeacherInfo = teacherInfo.GetSingleTeacher(id);

            return(Request.CreateResponse(System.Net.HttpStatusCode.OK, singleTeacherInfo));
        }
Exemple #3
0
        private void AddTeacher(Teachers entityToAdd)
        {
            ITeachersRepository repo = new TeachersRepository(getEntities());

            Entities.Teachers entityToAdd2 = Mapper.Map <Teachers, Entities.Teachers>(entityToAdd);
            repo.Add(entityToAdd2);
        }
Exemple #4
0
        private void teacherEditButton_Click(object sender, EventArgs e)
        {
            var selectedRowIndex = GetSelectedRowIndex(teachersDataGridView);

            if (selectedRowIndex == null)
            {
                return;
            }
            var teacher   = TeachersRepository.GetAll()[(int)selectedRowIndex];
            var teacherVM = new TeacherVM
            {
                Teacher    = teacher,
                SubjectIds = TeacherSubjectRepository.GetSubjectsForTeacher(teacher.Id),
            };

            new DetailedTeacherForm
            (
                teacherVM,
                SubjectsRepository.GetAll(),
                updatedTeacherVM =>
            {
                TeachersRepository.Update(updatedTeacherVM.Teacher);
                TeacherSubjectRepository.UpdateSubjectsForTeacher(updatedTeacherVM.Teacher.Id, updatedTeacherVM.SubjectIds);
                UpdateTeachersGrid();
                return(true);
            }
            ).Show();
        }
Exemple #5
0
        public void RemoveTeacher(Teachers entityToRemove)
        {
            ITeachersRepository repo = new TeachersRepository(getEntities());

            Entities.Teachers entityToRemove2 = Mapper.Map <Teachers, Entities.Teachers>(entityToRemove);
            repo.Remove(entityToRemove2);
        }
Exemple #6
0
        private void subjectEditButton_Click(object sender, EventArgs e)
        {
            var selectedRowIndex = GetSelectedRowIndex(subjectDataGridView);

            if (selectedRowIndex == null)
            {
                return;
            }
            var subject   = SubjectsRepository.GetAll()[(int)selectedRowIndex];
            var subjectVM = new SubjectVM
            {
                Subject    = subject,
                TeacherIds = TeacherSubjectRepository.GetTeachersForSubject(subject.Id),
            };

            new DetailedSubjectForm
            (
                subjectVM,
                TeachersRepository.GetAll(),
                updatedSubjectVM =>
            {
                SubjectsRepository.Update(updatedSubjectVM.Subject);
                TeacherSubjectRepository.UpdateTeachersForSubject(updatedSubjectVM.Subject.Id, updatedSubjectVM.TeacherIds);
                UpdateSubjectsGrid();
                return(true);
            }
            ).Show();
        }
Exemple #7
0
        public void AllItemsTest()
        {
            var repo = new TeachersRepository(_context);

            Assert.AreEqual(_context.Teachers.Count(), repo.AllItems.Count());
            var item1 = new Teacher
            {
                FirstName  = "Kate",
                MiddleName = "Mary",
                LastName   = "March",
                Department = _context.Departments.FirstOrDefault()
            };
            var item2 = new Teacher
            {
                FirstName  = "Mark",
                MiddleName = "Andrew",
                LastName   = "Nielsen",
                Department = _context.Departments.FirstOrDefault()
            };

            repo.AddItem(item1);
            repo.AddItem(item2);
            Assert.AreEqual(_context.Teachers.Count(), repo.AllItems.Count());
            _context.Teachers.Remove(item1);
            _context.Teachers.Remove(item2);
        }
Exemple #8
0
        public void ChangeItemTest()
        {
            //_context.Subjects.RemoveRange(_context.Subjects);
            var repo = new TeachersRepository(_context);
            var item = new Teacher
            {
                FirstName  = "Kate",
                MiddleName = "Mary",
                LastName   = "March",
                Department = _context.Departments.FirstOrDefault()
            };

            repo.AddItem(item);
            int Id = _context.Teachers.FirstOrDefault(x => x.FirstName == item.FirstName &&
                                                      x.MiddleName == item.MiddleName &&
                                                      x.LastName == item.LastName &&
                                                      x.Department.Id == item.Department.Id).Id;
            var newitem = repo.GetItem(Id);

            newitem.LastName = "Price";
            repo.ChangeItem(newitem);
            var changeditem = repo.GetItem(Id);;

            Assert.AreEqual(newitem.FirstName, changeditem.FirstName);
            Assert.AreEqual(newitem.MiddleName, changeditem.MiddleName);
            Assert.AreEqual(newitem.LastName, changeditem.LastName);
            Assert.AreEqual(newitem.Department.Id, changeditem.Department.Id);
            _context.Teachers.Remove(newitem);
        }
Exemple #9
0
        public HttpResponseMessage DisplayTeachers()
        {
            var teacherInfo     = new TeachersRepository();
            var displayTeachers = teacherInfo.GetTeachers();

            return(Request.CreateResponse(System.Net.HttpStatusCode.OK, displayTeachers));
        }
Exemple #10
0
        public HttpResponseMessage EditSingleTeacher(TeacherModel teacher)
        {
            var teacherRepo           = new TeachersRepository();
            var editSingleTeacherInfo = teacherRepo.UpdateTeacher(teacher);


            return(Request.CreateResponse(System.Net.HttpStatusCode.OK, editSingleTeacherInfo));
        }
        public override void SetUp()
        {
            base.SetUp();

            TeachersRepository.Add(Arg.Any <Teacher>()).Returns(new VoidResult());
            CoursesRepository.Add(Arg.Any <Course>()).Returns(new VoidResult())
            .AndDoes(ci => _course = ci.ArgAt <Course>(0));
        }
Exemple #12
0
        public IEnumerable <Teachers> GetAllTeachers()
        {
            ITeachersRepository             repo           = new TeachersRepository(getEntities());
            IEnumerable <Entities.Teachers> returnedValue  = repo.GetAll();
            IEnumerable <Teachers>          returnedValue2 = Mapper.Map <IEnumerable <Entities.Teachers>, IEnumerable <Teachers> >(returnedValue);

            return(returnedValue2);
        }
Exemple #13
0
 private void InitializeAppRepositories()
 {
     Students            = new StudentsRepository(Student);
     Teachers            = new TeachersRepository(Teacher);
     Subjects            = new SubjectRepository(Subject);
     LessonPlans         = new LessonPlanRepository(LessonPlan);
     StudentsLessonPlans = new StudentsLessonRepository(StudentsLessonPlan);
 }
Exemple #14
0
        public Teachers GetTeacherById(int entityToGetById)
        {
            ITeachersRepository repo = new TeachersRepository(getEntities());

            Entities.Teachers returnedValue  = repo.GetById(entityToGetById);
            Teachers          returnedValue2 = Mapper.Map <Entities.Teachers, Teachers>(returnedValue);

            return(returnedValue2);
        }
Exemple #15
0
        // DI DbContext into Unit Of Work
        public UnitOfWork(ApplicationDBContext _myAppDbContext)
        {
            myAppDbContext = _myAppDbContext;

            /* Initialise all our repositories
             * Declare Instance of Repositories implementing the Repositories interface */
            Student = new StudentRepository(myAppDbContext);
            Teacher = new TeachersRepository(myAppDbContext);
            Course  = new  CoursesRepository(myAppDbContext);
        }
        public void AddTeacher_ValidName_TeacherIsAdded()
        {
            // Arrange

            // Act
            _service.Add("Mohammad Helmy");

            // Assert
            TeachersRepository.Received().Add(Arg.Any <Teacher>());
        }
        public void All_ListIsCalled()
        {
            // Arrange

            // Act
            _service.All();

            // Assert
            TeachersRepository.Received().List();
        }
        public void Get_NotFound_ReturnNull()
        {
            // Arrange
            var id = TeachersRepository.NotFoundEntity();

            // Act
            var result = _service.Get(id);

            // Assert
            Assert.That(result, Is.Null);
        }
        public void Get_Found_ReturnIt()
        {
            // Arrange
            var teacher = TeachersRepository.FoundEntity();

            // Act
            var result = _service.Get(teacher.Id);

            // Assert
            Assert.That(result, Is.Not.Null);
        }
        protected void _TeacherFound_TeacherNameUpdated(Func <Guid, string> act)
        {
            // Arrange
            var teacher = TeachersRepository.FoundEntity();

            // Act
            var newName = act(teacher.Id);

            // Assert
            Assert.That(teacher.FullName, Is.EqualTo(newName));
        }
Exemple #21
0
        private void teacherDeleteButton_Click(object sender, EventArgs e)
        {
            var selectedRowIndex = GetSelectedRowIndex(teachersDataGridView);

            if (selectedRowIndex == null)
            {
                return;
            }
            TeachersRepository.Delete(TeachersRepository.GetAll()[(int)selectedRowIndex].Id);
            UpdateTeachersGrid();
        }
 public override void InitParams()
 {
     dbSet  = _context.Teachers;
     r      = new TeachersRepository(_context);
     model1 = new Teacher {
         FirstName = "Vasily", MiddleName = "Novak", LastName = "Sidorovich", Department = _context.Departments.FirstOrDefault()
     };
     model2 = new Teacher {
         FirstName = "Petro", MiddleName = "Limak", LastName = "Andreevich", Department = _context.Departments.FirstOrDefault()
     };
 }
Exemple #23
0
 private void teacherCreateButton_Click(object sender, EventArgs e) => new DetailedTeacherForm
 (
     null,
     SubjectsRepository.GetAll(),
     newTeacherVM =>
 {
     var newTeacherId = TeachersRepository.Add(newTeacherVM.Teacher).Id;
     TeacherSubjectRepository.AddSubjectsForTeacher(newTeacherId, newTeacherVM.SubjectIds);
     UpdateTeachersGrid();
     return(true);
 }
 ).Show();
Exemple #24
0
 private void subjectCreateButton_Click(object sender, EventArgs e) => new DetailedSubjectForm
 (
     null,
     TeachersRepository.GetAll(),
     newSubjectVM =>
 {
     var newSubjectId = SubjectsRepository.Add(newSubjectVM.Subject).Id;
     TeacherSubjectRepository.AddTeachersForSubject(newSubjectId, newSubjectVM.TeacherIds);
     UpdateSubjectsGrid();
     return(true);
 }
 ).Show();
        protected void _TeacherNotFound_Fail(Func <Guid, IVoidResult> act)
        {
            // Arrange
            var id = TeachersRepository.NotFoundEntity();

            // Act
            var result = act(id);

            // Assert
            Assert.That(result, Is.Not.Null);
            Assert.That(result.Succeed, Is.False);
        }
        protected void _TeacherIdIsEmpty_CreateTeacher(Func <IdNamePair, CourseDetails> act)
        {
            // Arrange
            var name = "Test teacher";

            // Act
            act(new IdNamePair {
                Id = Guid.Empty, Name = name
            });

            // Assert
            TeachersRepository.Received().Add(Arg.Any <Teacher>());
        }
        public void Update_TeacherNotFound_Failed()
        {
            // Arrange
            var fullName = "Mohammad Helmy";
            var id       = TeachersRepository.NotFoundEntity();

            // Act
            var result = _service.Update(id, fullName);

            // Assert
            Assert.That(result, Is.Not.Null);
            Assert.That(result.Succeed, Is.False);
        }
Exemple #28
0
 public ActionResult SaveTeachersChanges(TeachersViewModel vm)
 {
     try
     {
         TeachersRepository.UpdateTeachers(vm.AllTeachers);
         TempData["success"] = "1";
     }
     catch (Exception ex)
     {
         TempData["success"] = "0";
     }
     return(RedirectToAction("Show"));
 }
        public void Add_Valid_Saved()
        {
            // Arrange
            var teacher = TeachersRepository.FoundEntity();

            CourseDetails.Teacher.Id = teacher.Id;

            // Act
            Service.Create(CourseDetails);

            // Assert
            UnitOfWork.Received().SaveChanges();
        }
        public void Add_Valid_CourseAdded()
        {
            // Arrange
            var teacher = TeachersRepository.FoundEntity();

            CourseDetails.Teacher.Id = teacher.Id;

            // Act
            Service.Create(CourseDetails);

            // Assert
            CoursesRepository.Received().Add(Arg.Any <Course>());
        }
        public ScheduleRepository(string connectionString)
        {
            Database.SetInitializer(new MigrateDatabaseToLatestVersion<ScheduleContext, Configuration>());

            Auditoriums = new AuditoriumsRepository();
            Buildings = new BuildingsRepository();
            Calendars = new CalendarsRepository();
            Disciplines = new DisciplinesRepository();
            DisciplineNames = new DisciplineNameRepository();
            Lessons = new LessonsRepository(this);
            Rings = new RingsRepository();
            Students = new StudentsRepository();
            StudentGroups = new StudentGroupsRepository();
            StudentsInGroups = new StudentsInGroupsRepository();
            Teachers = new TeachersRepository();
            TeacherForDisciplines = new TeacherForDisciplinesRepository();
            ConfigOptions = new ConfigOptionRepository();

            AuditoriumEvents = new AuditoriumEventsRepository();

            Faculties = new FacultiesRepository();
            GroupsInFaculties = new GroupsInFacultiesRepository();

            ScheduleNotes = new ScheduleNotesRepository();

            LessonLogEvents = new LessonLogEventsRepository();

            TeacherWishes = new TeacherWishesRepository();

            CustomTeacherAttributes = new CustomTeacherAttributesRepository();
            CustomDisciplineAttributes = new CustomDisciplineAttributesRepository();
            CustomStudentGroupAttributes = new CustomStudentGroupAttributesRepository();

            Shifts = new ShiftsRepository();
            ShiftRings = new ShiftRingsRepository();

            Exams = new ExamsRepository();
            LogEvents = new LogEventsRepository();

            CommonFunctions = new CommonFunctions(this);

            SetConnectionString(connectionString);
        }