public JsonResult deleteCandidates(string cIds) { string msg = null; int status = 0; string errorCode = null; try { try { foreach (var cId in cIds.Split(',')) { status += _cds.deleteCandidates(Convert.ToInt32(cId)); } } catch (SqlException ex) { errorCode = ex.Number.ToString(); } msg = status > 0 ? "s" : "f"; msg = errorCode == "547" ? "ec" : msg; } catch (Exception ex) { msg = "Error:" + ex.Message; } return(Json(new { msg = msg }, JsonRequestBehavior.AllowGet)); }