public ActionResult Delete(detail Post) { if (ModelState.IsValid) { using (SLKDatabaseEntities db = new SLKDatabaseEntities()) { db.Entry(Post).State = System.Data.Entity.EntityState.Deleted; db.SaveChanges(); return(RedirectToAction("Home", "Home")); } } return(View(Post)); }
public IHttpActionResult DeleteEmployee(int id) { if (id <= 0) { return(BadRequest("Not a valid student id")); } using (var ctx = new SLKDatabaseEntities()) { var student = ctx.registrations .Where(s => s.SlNo == id) .FirstOrDefault(); ctx.Entry(student).State = System.Data.Entity.EntityState.Deleted; ctx.SaveChanges(); } return(Ok()); }