コード例 #1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,CourseId,TutorId")] Group @group)
        {
            if (id != @group.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(@group);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!GroupExists(@group.Id))
                    {
                        return(NotFound());
                    }

                    throw;
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CourseId"] = new SelectList(_context.Courses, "Id", "Name", @group.CourseId);
            ViewData["TutorId"]  = new SelectList(_context.Tutors, "Id", "Name", @group.TutorId);
            return(View(@group));
        }
コード例 #2
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,SubjectId,Name,Info")] Teacher teacher)
        {
            if (id != teacher.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(teacher);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TeacherExists(teacher.Id))
                    {
                        return(NotFound());
                    }

                    throw;
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["SubjectId"] = new SelectList(_context.Subjects, "Id", "Name", teacher.SubjectId);
            return(View(teacher));
        }
コード例 #3
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name")] Subject subject)
        {
            if (id != subject.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(subject);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!SubjectExists(subject.Id))
                    {
                        return(NotFound());
                    }

                    throw;
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(subject));
        }
コード例 #4
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Info")] Type @type)
        {
            if (id != @type.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(@type);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TypeExists(@type.Id))
                    {
                        return(NotFound());
                    }

                    throw;
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(@type));
        }
コード例 #5
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,TeacherId,Price,TypeId,Name,Info")] Course course)
        {
            if (id != course.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(course);
                    await _context.SaveChangesAsync();

                    return(RedirectToAction("Index", "Courses", new
                    {
                        id = course.TypeId,
                        name = _context.Types.FirstOrDefault(t => t.Id == course.TypeId)?.Name,
                        info = _context.Types.FirstOrDefault(t => t.Id == course.TypeId)?.Info
                    }));
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CourseExists(course.Id))
                    {
                        return(NotFound());
                    }
                    throw;
                }
            }
            //ViewData["TeacherId"] = new SelectList(_context.Teachers, "Id", "Name", course.TeacherId);
            //ViewData["TypeId"] = new SelectList(_context.Types, "Id", "Name", course.TypeId);
            //return View(course);
            return(RedirectToAction("Index", "Courses", new
            {
                id = course.TypeId,
                name = _context.Types.FirstOrDefault(t => t.Id == course.TypeId)?.Name,
                info = _context.Types.FirstOrDefault(t => t.Id == course.TypeId)?.Info
            }));
        }