public IActionResult Edit(int id, [Bind("Id,Name,Credits")] Subject subject)
        {
            if (id != subject.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(subject);
                    _context.SaveChanges();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!SubjectExists(subject.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(subject));
        }
        public IActionResult Edit(int id, [Bind("Id,SubjectId,TeacherId,StarTime,EndTime,Day")] TimeTable timeTable)
        {
            if (id != timeTable.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(timeTable);
                    _context.SaveChanges();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TimeTableExists(timeTable.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["SubjectId"] = new SelectList(_context.Subject, "Id", "Name", timeTable.SubjectId);
            ViewData["TeacherId"] = new SelectList(_context.Teacher, "Id", "ContactNumber", timeTable.TeacherId);
            return(View(timeTable));
        }
Beispiel #3
0
        public IActionResult Edit(int id, [Bind("Id,Name,ContactNumber")] Teacher teacher)
        {
            if (id != teacher.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(teacher);
                    _context.SaveChanges();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TeacherExists(teacher.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(teacher));
        }