public ActionResult DeleteConfirmed(int id) { string resultTrans = "success"; try { var prescriptionList = diagnosisRepository.GetPrescriptionByDiagnosisId(id); if (prescriptionList.Count() == 0) { DTODiagnosis dtodiagnosis = diagnosisRepository.GetDTODiagnosisById(id); Diagnosis originDiagnosis = diagnosisRepository.GetDiagnosisById(id); var newDiagnosis = ObjectCopier.Copy <Diagnosis>(originDiagnosis); newDiagnosis.Status = 0;//For Delete diagnosisRepository.UpdateFieldChangedOnly(originDiagnosis, newDiagnosis); /*For Add New Record to LogTable*/ var objSession = Session["user"] as MyClinic.Infrastructure.SessUser; int userId = objSession.UserId; logTran.UserId = userId; logTran.ProcessType = "Delete Diagnosis"; logTran.Description = "Delete Diagnosis, Patient Name :" + dtodiagnosis.Patient_Name; logTran.LogDate = DateTime.Now; logRepository.Add(logTran); } else { resultTrans = "failure"; return(Json(new { result = resultTrans, proccessType = "Delete", Id = id, strName = Translator.ThisDiagnosis, strUsed = Translator.MsgPrescription })); } } catch (Exception ex) { log.Error(ex); resultTrans = "failure"; } return(Json(new { result = resultTrans, proccessType = "Delete", Id = id })); }