public void DeleteTurno(IEnumerable<Model.TurnoModel> turnos)
        {
            using (var entity = new GestorDocumentEntities())
            {
                foreach (Model.TurnoModel p in turnos)
                {
                    GET_TURNO result = null;
                    try
                    {
                        result = (from o in entity.GET_TURNO
                                  where o.IdTurno == p.IdTurno
                                  select o).First();
                    }
                    catch (Exception)
                    {

                        throw;
                    }

                    if (result != null)
                    {
                        result.IsActive = false;
                        result.IsModified = true;
                        result.LastModifiedDate = new UNID().getNewUNID();
                    }
                }
                entity.SaveChanges();
                UpdateSyncLocal("GET_TURNO", entity);
            }
        }
        public Model.StatusAsuntoModel GetStatusAsuntoMod(Model.StatusAsuntoModel statusasunto)
        {
            using (var entity = new GestorDocumentEntities())
            {
                if (statusasunto != null)
                {
                    //Validar si el elemento ya existe
                    CAT_STATUS_ASUNTO result = null;
                    try
                    {
                        result = (from o in entity.CAT_STATUS_ASUNTO
                                  where
                                  o.StatusName == statusasunto.StatusName && o.IsActive == true
                                  select o).First();
                    }
                    catch (Exception ex)
                    {
                        ;
                    }

                    if (result == null)
                    {
                        statusasunto = null;
                    }

                }
            }
            return statusasunto;
        }
 public List<InstruccionModel> GetInstruccions()
 {
     List<InstruccionModel> Instruccions = new List<InstruccionModel>();
     using (var entity = new GestorDocumentEntities())
     {
         try
         {
             (from o in entity.CAT_INSTRUCCION
              where o.IsActive == true
              select o).OrderBy(o => o.InstruccionName).ToList().ForEach(p =>
              {
                  Instruccions.Add(new Model.InstruccionModel()
                  {
                      IdInstruccion = p.IdInstruccion,
                      CveInstruccion = p.CveInstruccion,
                      InstruccionName = p.InstruccionName,
                      IsActive = p.IsActive,
                      LastModifiedDate = p.LastModifiedDate,
                      IsModified = p.IsModified
                  });
              });
         }
         catch (Exception)
         {
             ;
         }
     }
     return Instruccions;
 }
        public void DeleteExpediente(IEnumerable<Model.ExpedienteModel> expedientes)
        {
            using (var entity = new GestorDocumentEntities())
            {
                foreach (Model.ExpedienteModel p in expedientes)
                {
                    GET_EXPEDIENTE result = null;
                    try
                    {
                        result = (from o in entity.GET_EXPEDIENTE
                                  where o.IdExpediente == p.IdExpediente
                                  select o).First();
                    }
                    catch (Exception)
                    {

                        throw;
                    }

                    if (result != null)
                    {
                        result.IsActive = false;
                        result.IsModified = true;
                        result.LastModifiedDate = new UNID().getNewUNID();
                    }
                }
                entity.SaveChanges();
                UpdateSyncLocal("GET_EXPEDIENTE", entity);
            }
        }
 public IEnumerable<Model.MenuModel> GetMenu(long IdRol)
 {
     ObservableCollection<Model.MenuModel> menu = new ObservableCollection<Model.MenuModel>();
     using (var entity = new GestorDocumentEntities())
     {
         try
         {
             (from o in entity.APP_MENU
              join rm in entity.APP_ROL_MENU
              on o.IdMenu equals rm.IdMenu
              join r in entity.APP_ROL
              on rm.IdRol equals r.IdRol
              where rm.IsActive == true && r.IdRol ==IdRol
              select o).ToList().ForEach(p =>
              {
                  menu.Add(new Model.MenuModel()
                  {
                      IdMenu = p.IdMenu,
                      IdMenuParent = p.IdMenuParent,
                      MenuName = p.MenuName,
                      IsActive = p.IsActive,
                      IsModified = p.IsModified,
                      LastModifiedDate = p.LastModifiedDate,
                      ServerLastModifiedDate = p.ServerLastModifiedDate,
                      PathMenu = p.PathMenu
                  });
              });
         }
         catch (Exception)
         {
             ;
         }
     }
     return menu;
 }
 public List<TipoDocumentoModel> GetTipoDocumentos()
 {
     List<TipoDocumentoModel> tipodocumentos = new List<TipoDocumentoModel>();
     using (var entity = new GestorDocumentEntities())
     {
         try
         {
             (from o in entity.CAT_TIPO_DOCUMENTO
              where o.IsActive == true
              select o).OrderBy(o => o.TipoDocumentoName).ToList().ForEach(p =>
              {
                  tipodocumentos.Add(new Model.TipoDocumentoModel()
                  {
                      IdTipoDocumento = p.IdTipoDocumento,
                      TipoDocumentoName = p.TipoDocumentoName,
                      //IsActive = p.IsActive,
                      //LastModifiedDate = p.LastModifiedDate,
                      //IsModified = p.IsModified
                  });
              });
         }
         catch (Exception)
         {
             ;
         }
     }
     return tipodocumentos;
 }
        public Model.RolModel getRol(long idUsuario)
        {
            Model.RolModel rol = new Model.RolModel();
            try
            {
                using (var entity=new GestorDocumentEntities())
                {
                    APP_ROL res;
                    res = (from r in entity.APP_ROL
                           join ur in entity.APP_USUARIO_ROL
                           on r.IdRol equals ur.IdRol
                           join u in entity.APP_USUARIO
                           on ur.IdUsuario equals u.IdUsuario
                           where u.IdUsuario == idUsuario
                           select r).FirstOrDefault();
                    if (res != null)
                    {
                        rol.IdRol = res.IdRol;
                        rol.RolName = res.RolName;
                    }
                }
            }
            catch (Exception)
            {

            }

            return rol;
        }
        public void DeleteDocumentos(IEnumerable<Model.DocumentosModel> documentos)
        {
            using (var entity = new GestorDocumentEntities())
            {
                foreach (Model.DocumentosModel p in documentos)
                {
                    GET_DOCUMENTOS result = null;
                    try
                    {
                        result = (from o in entity.GET_DOCUMENTOS
                                  where o.IdDocumento == p.IdDocumento
                                  select o).First();
                    }
                    catch (Exception)
                    {
                        ;
                    }

                    if (result != null)
                    {
                        result.IsActive = false;
                        result.IsModified = true;
                        result.LastModifiedDate = new UNID().getNewUNID();
                    }
                }
                entity.SaveChanges();
                UpdateSyncLocal("GET_DOCUMENTOS", entity);
            }
        }
        public void DeleteDestinatarioCcp(IEnumerable<Model.DestinatarioCcpModel> destinatariosCcp)
        {
            using (var entity = new GestorDocumentEntities())
            {
                foreach (Model.DestinatarioCcpModel p in destinatariosCcp)
                {
                    REL_DESTINATARIO_CCP result = null;
                    try
                    {
                        result = (from o in entity.REL_DESTINATARIO_CCP
                                  where o.IdDestinatarioCcp == p.IdDestinatarioCcp
                                  select o).First();
                    }
                    catch (Exception)
                    {
                        ;
                    }

                    if (result != null)
                    {
                        result.IsActive = false;
                        result.IsModified = true;
                        result.LastModifiedDate = new UNID().getNewUNID();
                    }
                }

                entity.SaveChanges();

                UpdateSyncLocal("REL_DESTINATARIO_CCP", entity);
            }
        }
        /// <summary>
        /// Ejecuta el stored SP_DASHBOARD_ATENDIDOS_INDICADOR que trae el calculo de los asuntos atendidos dentro y fuera de tiempo
        /// </summary>
        /// <param name="Determinantes">Lista de signatarios (determinantes externos)</param>
        /// <returns>AtendidoIndicadorModel con la cantidad de asuntos atendidos dentro y fueta de tiempo en base a la fecha actual (sistema)</returns>
        public Model.DashBoardModel.AtendidoIndicadorModel GetAtendidos(ObservableCollection<Model.DeterminanteModel> Determinantes)
        {
            Model.DashBoardModel.AtendidoIndicadorModel Atendido = null;

            //Obtener CSV
            string signatarios = this.GetSignatariosCSV(Determinantes);

            try
            {
                using (var entity = new GestorDocumentEntities())
                {
                    var atend = entity.SpDashboardAtendidosIndicador(signatarios).FirstOrDefault();
                    if (atend != null)
                    {
                        Atendido = new AtendidoIndicadorModel()
                        {
                            Dentro = (int)atend.AtendidosDentroVencimiento,
                            Fuera = (int)atend.AtendidosFueraVencimiento
                        };
                    }
                }
            }
            catch (Exception)
            {
                //TODO Log
            }
            return Atendido;
        }
 public System.Collections.ObjectModel.ObservableCollection<DeterminanteModel> GetDeterminante()
 {
     ObservableCollection<Model.DeterminanteModel> filtroSignatarios = new ObservableCollection<Model.DeterminanteModel>();
     try
     {
         using (var entity = new GestorDocumentEntities())
         {
             (from d in entity.CAT_DETERMINANTE
              orderby d.DeterminanteName ascending
              select d).ToList().ForEach(row =>
              {
                  Model.DeterminanteModel d = new Model.DeterminanteModel()
                  {
                      IdDeterminante = row.IdDeterminante,
                      DeterminanteName = row.DeterminanteName,
                      IsActive = false
                  };
                  filtroSignatarios.Add(d);
              });
         }
     }
     catch (Exception)
     {
         filtroSignatarios = null;
     }
     return filtroSignatarios;
 }
        public IEnumerable<Model.RolModel> GetDestinatarios()
        {
            ObservableCollection<Model.RolModel> filtroDestinatarios = new ObservableCollection<Model.RolModel>();
            using (var entity = new GestorDocumentEntities())
            {
                try
                {
                    (from r in entity.APP_ROL
                     where r.IdRol != 10
                     select r).OrderBy(o => o.RolName).ToList().ForEach(row =>
                         {
                             Model.RolModel r = new Model.RolModel()
                             {
                                 IdRol = row.IdRol,
                                 RolName = row.RolName,
                                 IsActive = false
                             };
                             filtroDestinatarios.Add(r);

                         });
                }
                catch (Exception)
                {
                    filtroDestinatarios = null;
                }
                return filtroDestinatarios;
            }
        }
 public List<StatusAsuntoModel> GetStatusAsuntos()
 {
     List<Model.StatusAsuntoModel> statusasuntos = new List<StatusAsuntoModel>();
     using (var entity = new GestorDocumentEntities())
     {
         try
         {
             (from o in entity.CAT_STATUS_ASUNTO
              where o.IsActive == true
              select o).OrderBy(o => o.StatusName).ToList().ForEach(p =>
              {
                  statusasuntos.Add(new Model.StatusAsuntoModel()
                  {
                      IdStatusAsunto = p.IdStatusAsunto,
                      StatusName = p.StatusName,
                      //IsActive = p.IsActive,
                      //LastModifiedDate = p.LastModifiedDate,
                      //IsModified = p.IsModified
                  });
              });
         }
         catch (Exception)
         {
             ;
         }
     }
     return statusasuntos;
 }
        /// <summary>
        /// Retorna el usuario en base a un mail y un password. Retorna null si el usuario y pass no coinciden
        /// </summary>
        /// <param name="userMail"></param>
        /// <param name="password"></param>
        /// <returns></returns>
        public Model.UsuarioModel GetUsuario(string userMail, string password)
        {
            Model.UsuarioModel um = null;

            using (var entity = new GestorDocumentEntities())
            {
                try
                {
                    var res = (from o in entity.APP_USUARIO
                               where o.UsuarioCorreo == userMail && o.UsuarioPwd == password
                               select o).First<APP_USUARIO>();

                    um = new Model.UsuarioModel()
                    {
                        IdUsuario = res.IdUsuario,
                        UsuarioCorreo = res.UsuarioCorreo,
                        Apellido = res.Apellido,
                        Area = res.Area,
                        Nombre = res.Nombre,
                        Puesto = res.Puesto,
                        UsuarioPwd = res.UsuarioPwd,
                        IsActive = res.IsActive,
                        Rol = this.getRol(res.IdUsuario)
                    };
                }
                catch (Exception ex)
                {
                    ;
                }
            }

            return um;
        }
        public void DeleteSignatario(IEnumerable<Model.SignatarioModel> signatarios)
        {
            using (var entity = new GestorDocumentEntities())
            {
                foreach (Model.SignatarioModel p in signatarios)
                {
                    REL_SIGNATARIO result = null;
                    try
                    {
                        result = (from o in entity.REL_SIGNATARIO
                                  where o.IdSignatario == p.IdSignatario
                                  select o).First();
                    }
                    catch (Exception)
                    {
                    }

                    if (result != null)
                    {
                        result.IsActive = false;
                        result.IsModified = true;
                        result.LastModifiedDate = new UNID().getNewUNID();
                    }
                }
                entity.SaveChanges();
                UpdateSyncLocal("REL_SIGNATARIO", entity);
            }
        }
        public Model.TipoDeterminanteModel GetTipoDeterminanteMod(Model.TipoDeterminanteModel tipodeterminante)
        {
            using (var entity = new GestorDocumentEntities())
            {
                if (tipodeterminante != null)
                {
                    //Validar si el elemento ya existe
                    CAT_TIPO_DETERMINANTE result = null;
                    try
                    {
                        result = (from o in entity.CAT_TIPO_DETERMINANTE
                                  where
                                  o.TipoDeterminanteName == tipodeterminante.TipoDeterminanteName && o.IsActive == true
                                  select o).First();
                    }
                    catch (Exception ex)
                    {
                        ;
                    }

                    if (result == null)
                    {
                        tipodeterminante = null;
                    }

                }
            }
            return tipodeterminante;
        }
        public Model.TurnoModel GetTurnoAdd(Model.TurnoModel turno)
        {
            using (var entity = new GestorDocumentEntities())
            {
                if (turno != null)
                {
                    //Validar si el elemento ya existe
                    GET_TURNO result = null;
                    try
                    {
                        result = (from o in entity.GET_TURNO
                                  where o.IdTurno == turno.IdTurno
                                  select o).First();
                    }
                    catch (Exception ex)
                    {
                        ;
                    }

                    if (result == null)
                    {
                        turno = null;
                    }

                }
            }
            return turno;
        }
        public void DeleteStatusAsunto(IEnumerable<Model.StatusAsuntoModel> statusasuntos)
        {
            using (var entity = new GestorDocumentEntities())
            {
                foreach (Model.StatusAsuntoModel p in statusasuntos)
                {
                    CAT_STATUS_ASUNTO result = null;
                    try
                    {
                        result = (from o in entity.CAT_STATUS_ASUNTO
                                  where o.IdStatusAsunto == p.IdStatusAsunto
                                  select o).First();
                    }
                    catch (Exception)
                    {

                        throw;
                    }

                    if (result != null)
                    {
                        result.IsActive = false;
                        result.IsModified = true;
                        result.LastModifiedDate = new UNID().getNewUNID();
                    }
                }
                entity.SaveChanges();
            }
        }
        public void DeleteTipoDeterminante(IEnumerable<Model.TipoDeterminanteModel> tipodeterminantes)
        {
            using (var entity = new GestorDocumentEntities())
            {
                foreach (Model.TipoDeterminanteModel p in tipodeterminantes)
                {
                    CAT_TIPO_DETERMINANTE result = null;
                    try
                    {
                        result = (from o in entity.CAT_TIPO_DETERMINANTE
                                  where o.IdTipoDeterminante == p.IdTipoDeterminante
                                  select o).First();
                    }
                    catch (Exception)
                    {

                        throw;
                    }

                    if (result != null)
                    {
                        result.IsActive = false;
                        result.IsModified = true;
                        result.LastModifiedDate = new UNID().getNewUNID();
                    }
                }
                entity.SaveChanges();
            }
        }
        public IEnumerable<Model.DeterminanteModel> GetSignatarios()
        {
            ObservableCollection<Model.DeterminanteModel> filtroSignatarios = new ObservableCollection<Model.DeterminanteModel>();
            try
            {
                using (var entity = new GestorDocumentEntities())
                {
                    (from d in entity.CAT_DETERMINANTE
                     select d).OrderBy(o=> o.DeterminanteName).ToList().ForEach(row =>
                     {
                         Model.DeterminanteModel d = new Model.DeterminanteModel()
                         {
                             IdDeterminante = row.IdDeterminante,
                             DeterminanteName = row.DeterminanteName,
                             IsActive = false
                         };
                         filtroSignatarios.Add(d);

                     });
                }
            }
            catch (Exception)
            {

                filtroSignatarios = null;
            }
            return filtroSignatarios;
        }
        public IEnumerable<Model.PrioridadModel> GetPrioridad()
        {
            ObservableCollection<Model.PrioridadModel> filtroPrioridad = new ObservableCollection<Model.PrioridadModel>();
            try
            {
                using (var entity = new GestorDocumentEntities())
                {
                    (from p in entity.CAT_PRIORIDAD
                     select p).OrderBy(o=> o.PrioridadName).ToList().ForEach(row =>
                         {
                             Model.PrioridadModel p = new Model.PrioridadModel()
                            {
                                IdPrioridad = row.IdPrioridad,
                                PrioridadName = row.PrioridadName,
                                IsActive = false
                            };
                             filtroPrioridad.Add(p);
                         });
                }
            }
            catch (Exception)
            {

            }
            return filtroPrioridad;
        }
        public Model.DestinatarioCcpModel GetDestinatarioCcpMod(Model.DestinatarioCcpModel destinatarioCcp)
        {
            using (var entity = new GestorDocumentEntities())
            {
                if (destinatarioCcp != null)
                {
                    //Validar si el elemento ya existe
                    REL_DESTINATARIO_CCP result = null;
                    try
                    {
                        result = (from o in entity.REL_DESTINATARIO_CCP
                                  where
                                  o.IdDestinatarioCcp == destinatarioCcp.IdDestinatarioCcp &&
                                  o.IdRol == destinatarioCcp.IdRol &&
                                  o.IdAsunto == destinatarioCcp.IdAsunto
                                  select o).First();
                    }
                    catch (Exception ex)
                    {
                        ;
                    }

                    if (result == null)
                    {
                        destinatarioCcp = null;
                    }

                }
            }
            return destinatarioCcp;
        }
        public Model.SignatarioModel GetSignatarioMod(Model.SignatarioModel signatario)
        {
            using (var entity = new GestorDocumentEntities())
            {
                if (signatario != null)
                {
                    //Validar si el elemento ya existe
                    REL_SIGNATARIO result = null;
                    try
                    {
                        result = (from o in entity.REL_SIGNATARIO
                                  where
                                  o.IdSignatario == signatario.IdSignatario &&
                                  o.IsActive == true &&
                                  o.IdDeterminante == signatario.IdDeterminante
                                  select o).First();
                    }
                    catch (Exception ex)
                    {
                        ;
                    }

                    if (result == null)
                    {
                        signatario = null;
                    }

                }
            }
            return signatario;
        }
 public IEnumerable<Model.DocumentosModel> GetDocumentos(long IdTurno)
 {
     ObservableCollection<Model.DocumentosModel> Documentos = new ObservableCollection<Model.DocumentosModel>();
     using (var entity = new GestorDocumentEntities())
     {
         try
         {
             (from a in entity.GET_ASUNTO
              join t in entity.GET_TURNO
              on a.IdAsunto equals t.IdAsunto
              join o in entity.GET_DOCUMENTOS
              on t.IdTurno equals o.IdTurno
              where o.IsActive == true && t.IdTurno ==IdTurno
              select o).ToList().ForEach(p =>
              {
                  Documentos.Add(new Model.DocumentosModel()
                  {
                      IdDocumento = p.IdDocumento,
                      DocumentoName = p.DocumentoName,
                      DocumentoPath = p.DocumentoPath,
                      Extencion = p.Extencion,
                      IsActive = p.IsActive,
                      IdTurno = p.IdTurno,
                      Fecha = p.Fecha,
                      IdExpediente = p.IdExpediente,
                      IdTipoDocumento = p.IdTipoDocumento,
                      TipoDocumento = new Model.TipoDocumentoModel()
                      {
                          TipoDocumentoName = p.CAT_TIPO_DOCUMENTO.TipoDocumentoName
                      },
                      IsDocumentoOriginal = p.IsDocumentoOriginal
                  });
              });
         }
         catch (Exception)
         {
             ;
         }
     }
     return Documentos;
 }
        public int GetRespuestaTurnos(long IdAsunto)
        {
            int result = 0;
            using (var entity = new GestorDocumentEntities())
            {

                try
                {
                    result = (from t in entity.GET_TURNO
                              where t.IdAsunto == IdAsunto
                                    && !t.IsTurnado
                                    && !t.IsAtendido
                              select t).Count();
                }
                catch (Exception)
                {
                    ;
                }
            }

            return result;
        }
 /// <summary>
 /// Ejecuta el spGetTablero para obtener la informacion del tablero principal.
 /// </summary>
 /// <param name="IdRol"></param>
 /// <returns></returns>
 public List<TableroModel> GetTablero(long IdRol)
 {
     List<TableroModel> items = new List<TableroModel>();
     try
     {
         using (var entity=new  GestorDocumentEntities())
         {
             entity.spGetTablero(IdRol).ToList().ForEach(row =>
             {
                 items.Add(new TableroModel()
                 {
                     IdTablero = row.IdTablero,
                     Categoria = row.CATEGORIA,
                     Total = (int)row.TOTAL
                 });
             });
         }
     }
     catch (Exception)
     {
     }
     return items;
 }
 public IEnumerable<Model.DestinatarioCcpModel> GetDestinatariosCcp(long IdAsunto)
 {
     ObservableCollection<Model.DestinatarioCcpModel> destinatarioCcp = new ObservableCollection<Model.DestinatarioCcpModel>();
     using (var entity = new GestorDocumentEntities())
     {
         try
         {
             (from o in entity.REL_DESTINATARIO_CCP
              join r in entity.APP_ROL
              on o.IdRol equals r.IdRol
              join or in entity.CAT_ORGANIGRAMA
              on o.IdRol equals or.IdRol
              where o.IsActive == true && o.IdAsunto == IdAsunto
              select new { o, or }).ToList().ForEach(p =>
              {
                  destinatarioCcp.Add(new Model.DestinatarioCcpModel()
                  {
                      IdDestinatarioCcp = p.o.IdDestinatarioCcp,
                      IdRol = p.o.IdRol,
                      Rol = new Model.RolModel()
                      {
                          IdRol = p.o.IdRol
                          ,
                          RolName = p.o.APP_ROL.RolName
                          ,
                          Organigrama = new Model.OrganigramaModel()
                          {
                              IdJerarquia = p.or.IdJerarquia,
                              JerarquiaName = p.or.JerarquiaName,
                              JerarquiaTitular =p.or.JerarquiaTitular
                          }
                      },
                      IdAsunto = p.o.IdAsunto,
                      IsActive = p.o.IsActive,
                      LastModidiedDate = p.o.LastModifiedDate,
                      IsModified = p.o.IsModified,
                      ServerLastModifiedDate = p.o.ServerLastModifiedDate
                  });
              });
         }
         catch (Exception)
         {
             ;
         }
     }
     return destinatarioCcp;
 }
        public void InsertDestinatarioCcp(IEnumerable<Model.DestinatarioCcpModel> destinatariosCcp)
        {
            using (var entity = new GestorDocumentEntities())
            {
                foreach (Model.DestinatarioCcpModel p in destinatariosCcp)
                {
                    REL_DESTINATARIO_CCP result = null;
                    try
                    {
                        result = (from o in entity.REL_DESTINATARIO_CCP
                                  where o.IdDestinatarioCcp == p.IdDestinatarioCcp
                                  select o).First();
                    }
                    catch (Exception)
                    {
                        ;
                    }

                    if (result == null)
                    {
                        entity.REL_DESTINATARIO_CCP.AddObject(
                            new REL_DESTINATARIO_CCP()
                            {
                                IdDestinatarioCcp = p.IdDestinatarioCcp
                                ,
                                IdRol = p.IdRol
                                ,
                                IdAsunto = p.IdAsunto
                                ,
                                IsActive = p.IsActive
                                ,
                                IsModified = true
                                ,
                                LastModifiedDate = new UNID().getNewUNID()
                            }
                        );
                    }
                }

                entity.SaveChanges();

                UpdateSyncLocal("REL_DESTINATARIO_CCP", entity);
            }
        }
        public void UpdateDestinatarioCcp(Model.DestinatarioCcpModel destinatarioCcp)
        {
            using (var entity = new GestorDocumentEntities())
            {
                if (destinatarioCcp != null)
                {
                    REL_DESTINATARIO_CCP result = null;
                    try
                    {
                        result = (from o in entity.REL_DESTINATARIO_CCP
                                  where o.IdDestinatarioCcp == destinatarioCcp.IdDestinatarioCcp
                                  select o).First();
                    }
                    catch (Exception ex)
                    {
                        ;
                    }

                    if (result != null)
                    {
                        result.IdDestinatarioCcp = destinatarioCcp.IdDestinatarioCcp;
                        result.IdRol = destinatarioCcp.IdRol;
                        result.IdAsunto = destinatarioCcp.IdAsunto;
                        result.IsModified = true;
                        result.LastModifiedDate = new UNID().getNewUNID();

                        entity.SaveChanges();

                        UpdateSyncLocal("REL_DESTINATARIO_CCP", entity);
                    }

                }
            }
        }
        public void InsertDestinatarioCcp(Model.DestinatarioCcpModel destinatarioCcp)
        {
            using (var entity = new GestorDocumentEntities())

                if (destinatarioCcp != null)
                {
                    //Validar si el elemento ya existe
                    REL_DESTINATARIO_CCP result = null;
                    try
                    {
                        result = (from o in entity.REL_DESTINATARIO_CCP
                                  where o.IdDestinatarioCcp == destinatarioCcp.IdDestinatarioCcp
                                  select o).First();
                    }
                    catch (Exception ex)
                    {
                        ;
                    }

                    if (result == null)
                    {
                        entity.REL_DESTINATARIO_CCP.AddObject(
                            new REL_DESTINATARIO_CCP()
                            {
                                IdDestinatarioCcp = destinatarioCcp.IdDestinatarioCcp,
                                IdRol = destinatarioCcp.IdRol,
                                IdAsunto = destinatarioCcp.IdAsunto,
                                IsModified = true,
                                LastModifiedDate = new UNID().getNewUNID()
                            }
                        );

                        entity.SaveChanges();

                        UpdateSyncLocal("REL_DESTINATARIO_CCP", entity);
                    }

                }
        }