public ActionResult DeleteConfirmed(int id) { using(var db = new RptContext()) { var report = db.Reports.Find(id); db.Reports.Remove(report); db.SaveChanges(); } return RedirectToAction("Index"); }
public ActionResult Create(ReportViewModel reportViewModel) { if (ModelState.IsValid) { reportViewModel.Report.CleanName(); using(var db = new RptContext()) { db.Reports.Add(reportViewModel.Report); db.SaveChanges(); } return RedirectToAction("Index"); } reportViewModel = RefreshViewModel(reportViewModel); return View(reportViewModel); }
public ActionResult Edit(ReportViewModel reportViewModel) { if (ModelState.IsValid) { reportViewModel.Report.CleanName(); using(var db = new RptContext()) { db.Entry(reportViewModel.Report).State = EntityState.Modified; db.SaveChanges(); } return RedirectToAction("Index"); } reportViewModel = RefreshViewModel(reportViewModel); return View(reportViewModel); }