コード例 #1
0
ファイル: SubjectsController.cs プロジェクト: mrakic96/RNWA
        public async Task <IActionResult> Edit(int id, [Bind("Id,DepartmentId,StartDate,EndDate,Name,FacultyId")] 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());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["DepartmentId"] = new SelectList(_context.Departments, "Id", "Name", subject.DepartmentId);
            ViewData["FacultyId"]    = new SelectList(_context.Faculties, "Id", "FirstName", subject.FacultyId);
            return(View(subject));
        }
コード例 #2
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,FirstName,LastName,DepartmentId,Phone")] Faculty faculty)
        {
            if (id != faculty.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(faculty);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!FacultyExists(faculty.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["DepartmentId"] = new SelectList(_context.Departments, "Id", "Name", faculty.DepartmentId);
            return(View(faculty));
        }
コード例 #3
0
        public async Task <IActionResult> Edit(int id, [Bind("RollNum,FirstName,LastName,DepartmentId,Phone,AdmissionDate,CetMarks")] Student student)
        {
            if (id != student.RollNum)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(student);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!StudentExists(student.RollNum))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["DepartmentId"] = new SelectList(_context.Departments, "Id", "Name", student.DepartmentId);
            return(View(student));
        }
コード例 #4
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,StudentRollNum,SubjectId,Marks")] Mark mark)
        {
            if (id != mark.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(mark);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!MarkExists(mark.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["StudentRollNum"] = new SelectList(_context.Students, "RollNum", "FirstName", mark.StudentRollNum);
            ViewData["SubjectId"]      = new SelectList(_context.Subjects, "Id", "Name", mark.SubjectId);
            return(View(mark));
        }