1 В избранное 0 Ответвления 0

OSCHINA-MIRROR/Storm_admin-APS_NET_MVC_EXAM

Присоединиться к Gitlife
Откройте для себя и примите участие в публичных проектах с открытым исходным кодом с участием более 10 миллионов разработчиков. Приватные репозитории также полностью бесплатны :)
Присоединиться бесплатно
Это зеркальный репозиторий, синхронизируется ежедневно с исходного репозитория.
Клонировать/Скачать
PapersController.cs 2.3 КБ
Копировать Редактировать Web IDE Исходные данные Просмотреть построчно История
Dream Отправлено 5 лет назад 42c2414
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using EXAM.Models;
namespace EXAM.Controllers
{
/// <summary>
/// 试卷管理控制器
/// </summary>
public class PapersController : Controller
{
ExamDBEntities db = new ExamDBEntities();
// GET: Papers
public ActionResult Index()
{
db.Configuration.LazyLoadingEnabled = false;
var da = db.Paper.ToList();
return View(da);
}
public ActionResult Create()
{
return View();
}
[HttpPost]
public ActionResult Create(Paper p)
{
if (p!=null)
{
db.Entry(p).State = System.Data.Entity.EntityState.Added;
db.SaveChanges();
}
return RedirectToAction("Index");
}
public ActionResult Delete(int id)
{
db.Configuration.LazyLoadingEnabled = false;
return View(db.Paper.Find(id));
}
[HttpPost]
public ActionResult Delete(string _HiddenId)
{
db.Entry(new Paper { PaperID = int.Parse(_HiddenId) }).State = EntityState.Deleted;
db.SaveChanges();
return RedirectToAction("Index");
}
public ActionResult Details(int id)
{
db.Configuration.LazyLoadingEnabled = false;
var da = db.Paper.Include("Topic").Where(p => p.PaperID == id).FirstOrDefault();
int sum = 0;
foreach (var item in da.Topic)
{
sum += item.TopicScore;
}
ViewBag.ZF = sum;
return View(da);
}
//试卷编辑
public ActionResult Edit(int id)
{
db.Configuration.LazyLoadingEnabled = false;
var da = db.Paper.Find(id);
return View(da);
}
[HttpPost]
public ActionResult Edit(Paper p)
{
db.Entry(p).State = EntityState.Modified;
db.SaveChanges();
return RedirectToAction("Index");
}
//学生
public ActionResult IndexStu()
{
return View();
}
}
}

Комментарий ( 0 )

Вы можете оставить комментарий после Вход в систему

1
https://gitlife.ru/oschina-mirror/Storm_admin-APS_NET_MVC_EXAM.git
git@gitlife.ru:oschina-mirror/Storm_admin-APS_NET_MVC_EXAM.git
oschina-mirror
Storm_admin-APS_NET_MVC_EXAM
Storm_admin-APS_NET_MVC_EXAM
master