private int SaveActions(decimal incidentId, List <TASK_STATUS> actionList)
        {
            PSsqmEntities entities = new PSsqmEntities();
            int           status   = 0;

            foreach (TASK_STATUS action in actionList)
            {
                if (!string.IsNullOrEmpty(action.DESCRIPTION) && action.DUE_DT.HasValue && action.RESPONSIBLE_ID.HasValue)
                {
                    EHSIncidentMgr.CreateOrUpdateTask(ActionIncident, action, WebSiteCommon.LocalTime(DateTime.UtcNow, IncidentLocationTZ));
                }
            }

            if (status > -1)
            {
                EHSNotificationMgr.NotifyIncidentStatus(ActionIncident, ((int)SysPriv.update).ToString(), "Corrective action specified");
            }

            EHSIncidentMgr.UpdateIncidentStatus(incidentId, IncidentStepStatus.correctiveaction, WebSiteCommon.LocalTime(DateTime.UtcNow, IncidentLocationTZ));

            return(status);
        }
        private int SaveActions(decimal incidentId, List <INCFORM_ACTION> itemList)
        {
            PSsqmEntities entities = new PSsqmEntities();
            int           status   = 0;

            using (var ctx = new PSsqmEntities())
            {
                ctx.ExecuteStoreCommand("DELETE FROM INCFORM_ACTION WHERE INCIDENT_ID = {0}", incidentId);
            }

            int seq = 0;

            foreach (INCFORM_ACTION item in itemList)
            {
                var newItem = new INCFORM_ACTION();

                if (!string.IsNullOrEmpty(item.ITEM_DESCRIPTION))
                {
                    seq = seq + 1;

                    newItem.INCIDENT_ID        = incidentId;
                    newItem.ITEM_SEQ           = seq;
                    newItem.ITEM_DESCRIPTION   = item.ITEM_DESCRIPTION;
                    newItem.ASSIGNED_PERSON_ID = item.ASSIGNED_PERSON_ID;
                    newItem.START_DATE         = item.START_DATE;
                    newItem.COMPLETION_DATE    = item.COMPLETION_DATE;
                    newItem.IsCompleted        = item.IsCompleted;
                    newItem.LAST_UPD_BY        = SessionManager.UserContext.Person.FIRST_NAME + " " + SessionManager.UserContext.Person.LAST_NAME;
                    newItem.LAST_UPD_DT        = DateTime.Now;

                    entities.AddToINCFORM_ACTION(newItem);
                    status = entities.SaveChanges();

                    DateTime dueDate = newItem.START_DATE.HasValue ? (DateTime)newItem.START_DATE : DateTime.Now.AddDays(2);
                    EHSIncidentMgr.CreateOrUpdateTask(incidentId, (decimal)item.ASSIGNED_PERSON_ID, 40, dueDate, item.ITEM_DESCRIPTION);
                }
            }
            return(status);
        }