ExamWeb/Controllers/PapersController.cs

(开头部分) 3KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using ExamWeb.Models;
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace ExamWeb.Controllers
{
    public class PapersController : Controller
    {
        // 试卷列表
        public ActionResult Index()
        {
            using (ExamDBEntities db = new ExamDBEntities())
            {
                var result = db.Paper.ToList();
                ViewBag.Paper = result;
            }
            return View();
        }

        //试卷列表
        public ActionResult IndexExam()
        {
            using (ExamDBEntities db = new ExamDBEntities())
            {
                var result = db.Paper.ToList();
                ViewBag.Paper = result;
            }
            return View();
        }

        //新增试卷
        public ActionResult Create()
        {
            return View();
        }
        [HttpPost]
        public ActionResult Create(Paper paper)
        {
            using (ExamDBEntities db = new ExamDBEntities())
            {
                var result = db.Paper.Add(paper);
                db.SaveChanges();
            }
            return RedirectToAction("Index");
        }

        //修改试卷
        [HttpPost]
        public ActionResult Eidt(Paper paper)
        {
            using (ExamDBEntities db = new ExamDBEntities())
            {
                try
                {
                    db.Entry(paper).State = EntityState.Modified;
                    db.SaveChanges();
后面还有 61 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。