public ActionResult ADDorEDIT(Person_details personal_Information) { using (db) { try { if (personal_Information.Id == 0) { var getGenderlist = db.Gender_detail.ToList(); SelectList list = new SelectList(getGenderlist, "Gender_Id", "Gender"); ViewBag.list = list; db.Person_details.Add(personal_Information); db.SaveChanges(); return(Json(new { success = true, message = "Saved Successfully", JsonRequestBehavior.AllowGet })); } else { db.Entry(personal_Information).State = EntityState.Modified; db.SaveChanges(); return(Json(new { success = true, message = "Updated Successfully", JsonRequestBehavior.AllowGet })); } } catch (Exception ex) { return(Json(new { success = false, message = "Update Failed", JsonRequestBehavior.AllowGet })); } } }
public ActionResult Delete(int id) { using (db) { Person_details personal_Information = db.Person_details.Where(x => x.Id == id).FirstOrDefault <Person_details>(); db.Person_details.Remove(personal_Information); db.SaveChanges(); return(Json(new { success = true, message = "Deleted Successfully", JsonRequestBehavior.AllowGet })); } }