예제 #1
0
        private int SaveContainment(decimal incidentId, List <INCFORM_CONTAIN> itemList)
        {
            PSsqmEntities entities = new PSsqmEntities();
            int           status   = 0;

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

            int seq = 0;

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


                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.LAST_UPD_BY        = SessionManager.UserContext.Person.FIRST_NAME + " " + SessionManager.UserContext.Person.LAST_NAME;
                    newItem.LAST_UPD_DT        = DateTime.Now;

                    entities.AddToINCFORM_CONTAIN(newItem);
                    status = entities.SaveChanges();
                }
            }
            return(status);
        }