public classTestController : Controller
{private LeaveEntities db = newLeaveEntities();//
//GET: /Test/
publicActionResult Index()
{returnView(db.termtimes.ToList());
}//
//GET: /Test/Details/5
public ActionResult Details(int id = 0)
{
termtime termtime=db.termtimes.Find(id);if (termtime == null)
{returnHttpNotFound();
}returnView(termtime);
}//
//GET: /Test/Create
publicActionResult Create()
{returnView();
}//
//POST: /Test/Create
[HttpPost]
[ValidateAntiForgeryToken]publicActionResult Create(termtime termtime)
{if(ModelState.IsValid)
{
db.termtimes.Add(termtime);
db.SaveChanges();return RedirectToAction("Index");
}returnView(termtime);
}//
//GET: /Test/Edit/5
public ActionResult Edit(int id = 0)
{
termtime termtime=db.termtimes.Find(id);if (termtime == null)
{returnHttpNotFound();
}returnView(termtime);
}//
//POST: /Test/Edit/5
[HttpPost]
[ValidateAntiForgeryToken]publicActionResult Edit(termtime termtime)
{if(ModelState.IsValid)
{
db.Entry(termtime).State=EntityState.Modified;
db.SaveChanges();return RedirectToAction("Index");
}returnView(termtime);
}//
//GET: /Test/Delete/5
public ActionResult Delete(int id = 0)
{
termtime termtime=db.termtimes.Find(id);if (termtime == null)
{returnHttpNotFound();
}returnView(termtime);
}//
//POST: /Test/Delete/5
[HttpPost, ActionName("Delete")]
[ValidateAntiForgeryToken]public ActionResult DeleteConfirmed(intid)
{
termtime termtime=db.termtimes.Find(id);
db.termtimes.Remove(termtime);
db.SaveChanges();return RedirectToAction("Index");
}protected override void Dispose(booldisposing)
{
db.Dispose();base.Dispose(disposing);
}
}