public ActionResult GetDefaultCPNMapping(int?subjectId = null, int?typeId = null, int?rootCauseId = null, bool?isAllStatus = null, int?take = null) { Logger.Info(_logMsg.Clear().SetPrefixMsg("Get Mapping").Add("subjectId", subjectId) .Add("typeId", typeId) .Add("rootCauseId", rootCauseId) .Add("isAllStatus", isAllStatus) .Add("take", take).ToInputLogString()); try { List <ComplaintMappingEntity> maps = _complaintFacade.GetComplaintMapping(subjectId, typeId, rootCauseId, isAllStatus, take); ComplaintSubjectEntity subj = null; ComplaintTypeEntity type = null; RootCauseEntity cause = null; if (maps != null) { if (maps.Count == 1) { ComplaintMappingEntity map = maps.FirstOrDefault(); subj = _complaintFacade.GetSubjectById(map.ComplaintSubjectId.Value); type = _complaintFacade.GetTypeById(map.ComplaintTypetId.Value); cause = _complaintFacade.GetRootCauseById(map.RootCauseId.Value); return(Json(new { IsSuccess = true, MappingId = map.ComplaintMappingId, ComplaintSubjectId = subj.ComplaintSubjectId, ComplaintSubjectName = subj.ComplaintSubjectName, ComplaintTypeId = type.ComplaintTypeId, ComplaintTypeName = type.ComplaintTypeName, RootCauseId = cause.RootCauseId, RootCauseName = cause.RootCauseName })); } } return(Json(new { IsSuccess = false, //ErrorMessage = $"No mapping found! <br />for subjectId [{subjectId}], typeId [{typeId}], rootCauseId [{rootCauseId}], isAllStatus [{isAllStatus}]" ErrorMessage = "" })); } catch (Exception ex) { Logger.Error("Exception occur:\n", ex); Logger.Info(_logMsg.Clear().SetPrefixMsg("Get Subject By Id").Add("Error Message", ex.Message).ToInputLogString()); return(Json(new { IsSuccess = false, ErrorMessage = ex.Message })); } }
public ActionResult GetTypeById(int typeId) { Logger.Info(_logMsg.Clear().SetPrefixMsg("Get Type By Id").Add("typeId", typeId).ToInputLogString()); try { ComplaintSubjectEntity subj = _complaintFacade.GetSubjectById(typeId); ComplaintMappingEntity map = _complaintFacade.GetComplaintMapping(typeId: typeId, isAllStatus: false, take: 1).FirstOrDefault(); ComplaintTypeEntity type = null; RootCauseEntity cause = null; if (map != null) { type = _complaintFacade.GetTypeById(map.ComplaintTypetId.Value); cause = _complaintFacade.GetRootCauseById(map.RootCauseId.Value); return(Json(new { IsSuccess = true, ComplaintSubjectId = subj.ComplaintSubjectId, ComplaintSubjectName = subj.ComplaintSubjectName, ComplaintTypeId = type?.ComplaintTypeId, ComplaintTypeName = type?.ComplaintTypeName, RootCauseId = cause?.RootCauseId, RootCauseName = cause?.RootCauseName })); } return(Json(new { IsSuccess = false, ErrorMessage = "" })); } catch (Exception ex) { Logger.Error("Exception occur:\n", ex); Logger.Info(_logMsg.Clear().SetPrefixMsg("Get CPNSubject By Id").Add("Error Message", ex.Message).ToInputLogString()); return(Json(new { IsSuccess = false, ErrorMessage = ex.Message })); } }
public ActionResult GetSubjectById(int subjectId) { Logger.Info(_logMsg.Clear().SetPrefixMsg("Get Subject By Id").Add("subjectId", subjectId).ToInputLogString()); try { ComplaintSubjectEntity subj = _complaintFacade.GetSubjectById(subjectId); return(Json(new { IsSuccess = true, ComplaintSubjectId = subj.ComplaintSubjectId, ComplaintSubjectName = subj.ComplaintSubjectName, })); } catch (Exception ex) { Logger.Error("Exception occur:\n", ex); Logger.Info(_logMsg.Clear().SetPrefixMsg("Get Subject By Id").Add("Error Message", ex.Message).ToInputLogString()); return(Json(new { IsSuccess = false, ErrorMessage = ex.Message })); } }