public ActionResult Delete(int id) { using (HISDBEntities db = new HISDBEntities()) { ScanCategory scg = db.ScanCategories.Where(x => x.SCID == id) .FirstOrDefault <ScanCategory>(); db.ScanCategories.Remove(scg); db.SaveChanges(); return(Json(new { success = true, message = "Deleted Successfully" }, JsonRequestBehavior.AllowGet)); } }
public ActionResult AddModify(ScanCategory scg) { using (HISDBEntities db = new HISDBEntities()) { if (scg.SCID == 0) { db.ScanCategories.Add(scg); db.SaveChanges(); return(Json(new { success = true, message = "Saved Successfully" }, JsonRequestBehavior.AllowGet)); } else { db.Entry(scg).State = EntityState.Modified; db.SaveChanges(); return(Json(new { success = true, message = "Updated Successfully" }, JsonRequestBehavior.AllowGet)); } } }
//Get contact by ID public ScanCategory GetScanCategory(int categoryID) { ScanCategory scanCategory = null; using (HISDBEntities dc = new HISDBEntities()) { var v = (from a in dc.ScanCategories join b in dc.Scans on a.ScanID equals b.ScanID where a.SCID.Equals(categoryID) select new { a, b.ScanName, }).FirstOrDefault(); if (v != null) { scanCategory = v.a; scanCategory.ScanName = v.ScanName; } return(scanCategory); } }