protected int SaveRootCauses(decimal incidentId, List <INCFORM_ROOT5Y> itemList) { PSsqmEntities entities = new PSsqmEntities(); int status = 0; using (var ctx = new PSsqmEntities()) { ctx.ExecuteStoreCommand("DELETE FROM INCFORM_ROOT5Y WHERE INCIDENT_ID = {0}", incidentId); } int seq = 0; foreach (INCFORM_ROOT5Y item in itemList) { var newItem = new INCFORM_ROOT5Y(); if (!string.IsNullOrEmpty(item.ITEM_DESCRIPTION)) { seq = seq + 1; newItem.INCIDENT_ID = incidentId; newItem.ITEM_SEQ = seq; newItem.ITEM_DESCRIPTION = item.ITEM_DESCRIPTION; newItem.LAST_UPD_BY = SessionManager.UserContext.Person.FIRST_NAME + " " + SessionManager.UserContext.Person.LAST_NAME; newItem.LAST_UPD_DT = DateTime.Now; entities.AddToINCFORM_ROOT5Y(newItem); status = entities.SaveChanges(); } } return(status); }
protected int SaveRootCauses(decimal incidentId, List <INCFORM_ROOT5Y> itemList) { PSsqmEntities entities = new PSsqmEntities(); int status = 0; using (var ctx = new PSsqmEntities()) { ctx.ExecuteStoreCommand("DELETE FROM INCFORM_ROOT5Y WHERE INCIDENT_ID = {0}", incidentId); } int seq = 0; foreach (INCFORM_ROOT5Y item in itemList) { var newItem = new INCFORM_ROOT5Y(); if (!string.IsNullOrEmpty(item.ITEM_DESCRIPTION)) { seq = seq + 1; newItem.INCIDENT_ID = incidentId; newItem.ITEM_SEQ = seq; newItem.ITEM_TYPE = item.ITEM_TYPE; newItem.PROBLEM_SERIES = item.PROBLEM_SERIES; newItem.ITEM_DESCRIPTION = item.ITEM_DESCRIPTION; newItem.IS_ROOTCAUSE = item.IS_ROOTCAUSE; newItem.LAST_UPD_BY = SessionManager.UserContext.Person.FIRST_NAME + " " + SessionManager.UserContext.Person.LAST_NAME; newItem.LAST_UPD_DT = WebSiteCommon.LocalTime(DateTime.UtcNow, IncidentLocationTZ); entities.AddToINCFORM_ROOT5Y(newItem); status = entities.SaveChanges(); } } if (seq > 0) { EHSIncidentMgr.UpdateIncidentStatus(incidentId, IncidentStepStatus.rootcause, WebSiteCommon.LocalTime(DateTime.UtcNow, IncidentLocationTZ)); } return(status); }