Hello Team,
Please am trying to delete data from two table but is not working, kindly assist.
public ActionResult DeleteStaff(int StaffId, int CompanyId) { try { ASPNETMASTERPOSTEntities db = new ASPNETMASTERPOSTEntities(); var company = db.tblCompany.Where(x => x.CompanyId == CompanyId ).FirstOrDefault(); var Staff = db.tblStaffs.Where(x => x.StaffId == StaffId ).FirstOrDefault();
db.tblCompany.Remove(company); db.tblStaffs.Remove(Staff); db.SaveChanges(); return Json(true, JsonRequestBehavior.AllowGet); } catch (Exception) { return Json(false, JsonRequestBehavior.AllowGet); }
}