public void AddProtocolSystemUser(ref OperationResult pobjOperationResult, List <protocolsystemuserDto> ListProtocolSystemUserDto, int?pintSystemUserId, List <string> ClientSession, bool pbRegisterLog) { int SecuentialId = -1; string newId; try { SigesoftEntitiesModel dbContext = new SigesoftEntitiesModel(); foreach (var item in ListProtocolSystemUserDto) { // Autogeneramos el Pk de la tabla SecuentialId = Utils.GetNextSecuentialId(Int32.Parse(ClientSession[0]), 44); newId = Common.Utils.GetNewId(int.Parse(ClientSession[0]), SecuentialId, "PU"); // Grabar como nuevo var objEntity = protocolsystemuserAssembler.ToEntity(item); objEntity.v_ProtocolSystemUserId = newId; if (pintSystemUserId == null) { objEntity.i_SystemUserId = item.i_SystemUserId; } else { objEntity.i_SystemUserId = pintSystemUserId.Value; } objEntity.d_InsertDate = DateTime.Now; objEntity.i_InsertUserId = Int32.Parse(ClientSession[2]); objEntity.i_IsDeleted = 0; dbContext.AddToprotocolsystemuser(objEntity); } dbContext.SaveChanges(); pobjOperationResult.Success = 1; if (pbRegisterLog == true) { // Llenar entidad Log LogBL.SaveLog(ClientSession[0], ClientSession[1], ClientSession[2], LogEventType.CREACION, "ProtocolSystemUser", null, Success.Ok, null); } return; } catch (Exception ex) { pobjOperationResult.Success = 0; pobjOperationResult.ExceptionMessage = Common.Utils.ExceptionFormatter(ex); LogBL.SaveLog(ClientSession[0], ClientSession[1], ClientSession[2], LogEventType.CREACION, "ProtocolSystemUser", string.Empty, Success.Failed, pobjOperationResult.ExceptionMessage); return; } }