Exemple #1
0
        private void AddTeacher(Teachers entityToAdd)
        {
            ITeachersRepository repo = new TeachersRepository(getEntities());

            Entities.Teachers entityToAdd2 = Mapper.Map <Teachers, Entities.Teachers>(entityToAdd);
            repo.Add(entityToAdd2);
        }
        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 #3
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();
        public ActionResult Create([Bind(Include = "TeacherId,FirstName,LastName,TeacherTitle")] TeacherVM teacherVM)
        {
            if (ModelState.IsValid)
            {
                Teacher teacher = TeacherMap.TeacherVMToTeacher(teacherVM);

                teachersRepo.Add(teacher);

                return(RedirectToAction("Index"));
            }

            return(View(teacherVM));
        }
Exemple #5
0
        public void AddUser(Users entityToAdd)
        {
            IUsersRepository repo = new UsersRepository(getEntities());

            Entities.Users entityToAdd2 = Mapper.Map <Users, Entities.Users>(entityToAdd);
            repo.Add(entityToAdd2);
            switch (entityToAdd.UserType.ToUpper())
            {
            case "ADMINISTRATOR":
                IAdministratorsRepository adminRepo = new AdministratorsRepository(getEntities());
                Entities.Administrators   admin     = new Entities.Administrators()
                {
                    UserId = entityToAdd.Id
                };
                adminRepo.Add(admin);
                break;

            case "MANAGER":
                IManagersRepository managerRepo = new ManagersRepository(getEntities());
                Entities.Managers   manager     = new Entities.Managers()
                {
                    UserId = entityToAdd.Id
                };
                managerRepo.Add(manager);
                break;

            case "STUDENT":
                IStudentsRepository studentRepo = new StudentsRepository(getEntities());
                Entities.Students   student     = new Entities.Students()
                {
                    UserId = entityToAdd.Id
                };
                studentRepo.Add(student);
                break;

            case "TEACHER":
                ITeachersRepository teacherRepo = new TeachersRepository(getEntities());
                Entities.Teachers   teacher     = new Entities.Teachers()
                {
                    UserId = entityToAdd.Id
                };
                teacherRepo.Add(teacher);
                break;

            default:; break;
            }
        }