public JsonResult saveCandidates(Candidates c, List <EducationDetails> listEduDetail, List <ExperienceDetails> listExpDetail) { string msg = null; int cId = 0; try { c.crtUserId = MySession.userId; cId = _cds.saveCandidates(c); if (cId != 0) { if (listEduDetail != null) { foreach (EducationDetails ed in listEduDetail) { ed.cId = cId; if (ed.currentlyPursuing == true) { ed.toMonth = string.Empty; ed.toYear = 0; } _cds.saveEducationDetails(ed); } } if (listExpDetail != null) { foreach (ExperienceDetails ex in listExpDetail) { if (ex.currentlyWork == true) { ex.toMonth = string.Empty; ex.toYear = 0; } ex.cId = cId; _cds.saveExperienceDetails(ex); } } } msg = cId > 0 ? "s" : "f"; } catch (Exception ex) { msg = "Error:" + ex.Message; } return(Json(new { msg = msg, cId = cId }, JsonRequestBehavior.AllowGet)); }