Exemple #1
0
        public int SetIntegrantesGrupos(int id_grupo, string id_usuario_integrante)
        {
            try
            {
                // Realizamos la conexión a través de EntityFramework
                using (var Conexion = new EntitiesControlDocumentos())
                {
                    // Declaramos el objeto de la tabla
                    TR_INTEGRANTES_GRUPO obj = new TR_INTEGRANTES_GRUPO();

                    // Asignamos valores
                    obj.ID_GRUPO = id_grupo;
                    obj.ID_USUARIO_INTEGRANTE = id_usuario_integrante;

                    // Agregamos el objeto a la tabla
                    Conexion.TR_INTEGRANTES_GRUPO.Add(obj);

                    // Guardamos cambios
                    Conexion.SaveChanges();

                    // Retornamos el id
                    return(obj.ID_INTEGRANTES_GRUPO);
                }
            }
            catch (Exception)
            {
                // Si hay error retornamos 0
                return(0);
            }
        }
Exemple #2
0
        public int DeleteIntegrantesGrupos(int id_grupo, string id_integrante)
        {
            try
            {
                // Realizamos la conexion
                using (var Conexion = new EntitiesControlDocumentos())
                {
                    // Declaramos el objeto de la tabla
                    TR_INTEGRANTES_GRUPO obj = Conexion.TR_INTEGRANTES_GRUPO.Where(x => x.ID_GRUPO == id_grupo && x.ID_USUARIO_INTEGRANTE == id_integrante).FirstOrDefault();

                    // Guardamos los cambios
                    Conexion.Entry(obj).State = System.Data.Entity.EntityState.Deleted;
                    return(Conexion.SaveChanges());
                }
            }
            catch (Exception)
            {
                // Si hay error retornamos 0
                return(0);
            }
        }