Exemplo n.º 1
0
        public IActionResult TeacherDisciplineNameEdit(int teacherId,
                                                       TeacherEduProfileDisciplineName teacherEduProfileDisciplineName)
        {
            var teacher = _structSubvisionChiefRepository.GetTeachersOfKafedra(User.Identity.Name)
                          .FirstOrDefault(t => t.TeacherId == teacherId);

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

            ViewBag.Teacher = teacher;

            var teacherDisciplineNameEntry = teacher.TeacherEduProfileDisciplineNames
                                             .Single(td => td.TeacherEduProfileDisciplineNameId == teacherEduProfileDisciplineName.TeacherEduProfileDisciplineNameId);

            ViewBag.DisciplineNames = _selectListRepository.GetSelectListDisciplines(teacherDisciplineNameEntry.DisciplineNameId);

            if (teacherDisciplineNameEntry != null)
            {
                teacherDisciplineNameEntry.DisciplineNameId = teacherEduProfileDisciplineName.DisciplineNameId;
                _structSubvisionChiefRepository.UpdateTeacherDisciplineName(teacherDisciplineNameEntry);

                return(RedirectToAction(nameof(TeacherDisciplineNamesEdit), new { teacherId = teacher.TeacherId }));
            }

            return(View(teacherDisciplineNameEntry));
        }
        public async Task <IActionResult> Create(TeacherEduProfileDisciplineName teacherEduProfileDisciplineName,
                                                 string fioSearch)
        {
            if (ModelState.IsValid)
            {
                _context.Add(teacherEduProfileDisciplineName);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index), new { fioSearch }));
            }

            ViewBag.fioSearch            = fioSearch;
            ViewData["DisciplineNameId"] = new SelectList(_context.DisciplineNames.OrderBy(d => d.DisciplineNameName), "DisciplineNameId", "DisciplineNameName", teacherEduProfileDisciplineName.DisciplineNameId);
            ViewData["EduProfileId"]     = new SelectList(_context.EduProfiles.Include(p => p.EduNapravl.EduUgs.EduLevel), "EduProfileId", "GetEduProfileFullName", teacherEduProfileDisciplineName.EduProfileId);
            ViewData["TeacherId"]        = new SelectList(_context.Teachers.OrderBy(t => t.TeacherFio), "TeacherId", "TeacherFio", teacherEduProfileDisciplineName.TeacherId);

            return(View(teacherEduProfileDisciplineName));
        }
Exemplo n.º 3
0
        public IActionResult TeacherDisciplineNameCreate(int teacherId)
        {
            var teacher = _structSubvisionChiefRepository.GetTeachersOfKafedra(User.Identity.Name)
                          .FirstOrDefault(t => t.TeacherId == teacherId);

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

            var teacherDisciplineNameEntry = new TeacherEduProfileDisciplineName {
                TeacherId = teacherId
            };

            ViewBag.Teacher         = teacher;
            ViewBag.DisciplineNames = _selectListRepository.GetSelectListDisciplines();
            return(View(teacherDisciplineNameEntry));
        }
Exemplo n.º 4
0
        public IActionResult TeacherDisciplineNameDelete(TeacherEduProfileDisciplineName teacherDisciplineName)
        {
            var teacher = _structSubvisionChiefRepository.GetTeachersOfKafedra(User.Identity.Name)
                          .FirstOrDefault(t => t.TeacherId == teacherDisciplineName.TeacherId);

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

            var teacherDisciplineNameEntry = teacher.TeacherEduProfileDisciplineNames
                                             .Single(td => td.TeacherEduProfileDisciplineNameId == teacherDisciplineName.TeacherEduProfileDisciplineNameId);

            if (teacherDisciplineNameEntry != null)
            {
                _structSubvisionChiefRepository.RemoveTeacherDisciplineName(teacherDisciplineNameEntry);
            }

            return(RedirectToAction(nameof(TeacherDisciplineNamesEdit), new { teacherId = teacher.TeacherId }));
        }
Exemplo n.º 5
0
        public IActionResult TeacherDisciplineNameCreate(int teacherId,
                                                         TeacherEduProfileDisciplineName teacherEduProfileDisciplineName)
        {
            var teacher = _structSubvisionChiefRepository.GetTeachersOfKafedra(User.Identity.Name)
                          .FirstOrDefault(t => t.TeacherId == teacherId);

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

            ViewBag.Teacher = teacher;

            var teacherDisciplineNameEntry = new TeacherEduProfileDisciplineName();

            teacherDisciplineNameEntry.TeacherId        = teacher.TeacherId;
            teacherDisciplineNameEntry.DisciplineNameId = teacherEduProfileDisciplineName.DisciplineNameId;
            _structSubvisionChiefRepository.AddTeacherDisciplineName(teacherDisciplineNameEntry);

            return(RedirectToAction(nameof(TeacherDisciplineNamesEdit), new { teacherId = teacher.TeacherId }));
        }
        public async Task <IActionResult> Edit(int id, [Bind("TeacherEduProfileDisciplineNameId,TeacherId,EduProfileId,DisciplineNameId")] TeacherEduProfileDisciplineName teacherEduProfileDisciplineName,
                                               string fioSearch)
        {
            if (id != teacherEduProfileDisciplineName.TeacherEduProfileDisciplineNameId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(teacherEduProfileDisciplineName);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TeacherEduProfileDisciplineNameExists(teacherEduProfileDisciplineName.TeacherEduProfileDisciplineNameId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index), new { fioSearch }));
            }

            ViewBag.fioSearch            = fioSearch;
            ViewData["DisciplineNameId"] = new SelectList(_context.DisciplineNames.OrderBy(d => d.DisciplineNameName), "DisciplineNameId", "DisciplineNameName", teacherEduProfileDisciplineName.DisciplineNameId);
            ViewData["EduProfileId"]     = new SelectList(_context.EduProfiles.Include(p => p.EduNapravl.EduUgs.EduLevel), "EduProfileId", "GetEduProfileFullName", teacherEduProfileDisciplineName.EduProfileId);
            ViewData["TeacherId"]        = new SelectList(_context.Teachers.OrderBy(t => t.TeacherFio), "TeacherId", "TeacherFio", teacherEduProfileDisciplineName.TeacherId);

            return(View(teacherEduProfileDisciplineName));
        }