// GET: Teachers
        public ActionResult Index()
        {
            var teachers = teachersRepo.GetAll();

            var teachersVM = TeacherMap.TeachersToTeachersVM(teachers);

            return(View(teachersVM));
        }
Ejemplo n.º 2
0
 protected override void OnModelCreating(ModelBuilder modelBuilder)
 {
     base.OnModelCreating(modelBuilder);
     _ = new TeacherMap(modelBuilder.Entity <Teacher>());
     _ = new StudentMap(modelBuilder.Entity <Student>());
     _ = new LectureMap(modelBuilder.Entity <Lecture>());
     _ = new CourseMap(modelBuilder.Entity <Course>());
     _ = new EnrollmentMap(modelBuilder.Entity <Enrollment>());
     _ = new SemesterMap(modelBuilder.Entity <Semester>());
 }
        public ActionResult Edit([Bind(Include = "TeacherId,FirstName,LastName,TeacherTitle")] TeacherVM teacherVM)
        {
            if (ModelState.IsValid)
            {
                Teacher teacher = TeacherMap.TeacherVMToTeacher(teacherVM);

                teachersRepo.Edit(teacher);

                return(RedirectToAction("Index"));
            }
            return(View(teacherVM));
        }
        // GET: Teachers/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            Teacher teacher = teachersRepo.GetById(id.Value);

            if (teacher == null)
            {
                return(HttpNotFound());
            }

            var teacherVM = TeacherMap.TeacherToTeacherVM(teacher);

            return(View(teacherVM));
        }