using System; using System.Collections.Generic; using System.Data; using System.Data.Entity; using System.Linq; using System.Web; using System.Web.Mvc; namespace AspMvcJQuery.Controllers { public class SampleController : Controller { private MvcJQueryDB db = new MvcJQueryDB(); // // GET: /Sample/ public ActionResult Index() { return View(db.Samples.ToList()); } // // GET: /Sample/Details/5 public ActionResult Details(long id = 0) { Sample sample = db.Samples.Single(s => s.SampleId == id); if (sample == null) { return HttpNotFound(); } return View(sample); } // // GET: /Sample/Create public ActionResult Create() { return View(); } // // POST: /Sample/Create [HttpPost] public ActionResult Create(Sample sample) { if (ModelState.IsValid) { db.Samples.AddObject(sample); db.SaveChanges(); return RedirectToAction("Index"); } return View(sample); } // // GET: /Sample/Edit/5 public ActionResult Edit(long id = 0) { Sample sample = db.Samples.Single(s => s.SampleId == id); if (sample == null) { return HttpNotFound(); } return View(sample); } // // POST: /Sample/Edit/5 [HttpPost] public ActionResult Edit(Sample sample) { if (ModelState.IsValid) { db.Samples.Attach(sample); db.ObjectStateManager.ChangeObjectState(sample, EntityState.Modified); db.SaveChanges(); return RedirectToAction("Index"); } return View(sample); } // // GET: /Sample/Delete/5 public ActionResult Delete(long id = 0) { Sample sample = db.Samples.Single(s => s.SampleId == id); if (sample == null) { return HttpNotFound(); } return View(sample); } // // POST: /Sample/Delete/5 [HttpPost, ActionName("Delete")] public ActionResult DeleteConfirmed(long id) { Sample sample = db.Samples.Single(s => s.SampleId == id); db.Samples.DeleteObject(sample); db.SaveChanges(); return RedirectToAction("Index"); } protected override void Dispose(bool disposing) { db.Dispose(); base.Dispose(disposing); } } }Dosyayı İndir