public ActionResult DeleteRecord(int id) { TechDetail techDetail = db.TechDetails.Find(id); db.TechDetails.Remove(techDetail); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult EditRecord(TechDetail techDetail) { //if data is valid then save in database if (ModelState.IsValid) { db.Entry(techDetail).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } //if data not valid then return to edit page to fix the problem return(View(techDetail)); }
public ActionResult CreatRecord(TechDetail techDetail) { //if model state is not valid then retur to creat so use can fix it if (!ModelState.IsValid) { return(View(techDetail)); } //if data is valid db.TechDetails.Add(techDetail); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult DeleteRecord(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } TechDetail techDetail = db.TechDetails.Find(id); if (techDetail == null) { return(HttpNotFound()); } return(View(techDetail)); }