Exemplo n.º 1
0
        public string Agregar(proyectos_involucrados entidad)
        {
            try
            {
                Model context = new Model();
                proyectos_involucrados involucrado = new proyectos_involucrados
                {
                    id_proyecto    = entidad.id_proyecto,
                    id_rol         = entidad.id_rol,
                    nombre         = entidad.nombre,
                    telefono       = entidad.telefono,
                    celular        = entidad.celular,
                    no_empleado    = entidad.no_empleado,
                    correo         = entidad.correo,
                    usuario        = entidad.usuario,
                    fecha_registro = DateTime.Now
                };
                context.proyectos_involucrados.Add(involucrado);
                context.SaveChanges();
                return("");
            }
            catch (DbEntityValidationException ex)
            {
                // Retrieve the error messages as a list of strings.
                var errorMessages = ex.EntityValidationErrors
                                    .SelectMany(x => x.ValidationErrors)
                                    .Select(x => x.ErrorMessage);

                // Join the list to a single string.
                var fullErrorMessage = string.Join("; ", errorMessages);

                return(fullErrorMessage.ToString());
            }
        }
Exemplo n.º 2
0
        public string Borrar(proyectos_involucrados entidad)
        {
            try
            {
                Model context = new Model();
                proyectos_involucrados involucrado = context.proyectos_involucrados
                                                     .First(i => i.id_pinvolucrado == entidad.id_pinvolucrado);
                involucrado.id_pinvolucrado     = entidad.id_pinvolucrado;
                involucrado.usuario_borrado     = entidad.usuario_borrado;
                involucrado.fecha_borrado       = DateTime.Now;
                involucrado.comentarios_borrado = entidad.comentarios_borrado;
                context.SaveChanges();
                return("");
            }
            catch (DbEntityValidationException ex)
            {
                // Retrieve the error messages as a list of strings.
                var errorMessages = ex.EntityValidationErrors
                                    .SelectMany(x => x.ValidationErrors)
                                    .Select(x => x.ErrorMessage);

                // Join the list to a single string.
                var fullErrorMessage = string.Join("; ", errorMessages);

                return(fullErrorMessage.ToString());
            }
        }
Exemplo n.º 3
0
        public string Editar(proyectos_involucrados entidad)
        {
            try
            {
                Model context = new Model();
                proyectos_involucrados involucrado = context.proyectos_involucrados
                                                     .First(i => i.id_pinvolucrado == entidad.id_pinvolucrado);
                involucrado.nombre          = entidad.nombre;
                involucrado.id_rol          = entidad.id_rol;
                involucrado.telefono        = entidad.telefono;
                involucrado.no_empleado     = entidad.no_empleado;
                involucrado.correo          = entidad.correo;
                involucrado.celular         = entidad.celular;
                involucrado.usuario_edicion = entidad.usuario_edicion;
                involucrado.fecha_edicion   = DateTime.Now;
                context.SaveChanges();
                return("");
            }
            catch (DbEntityValidationException ex)
            {
                // Retrieve the error messages as a list of strings.
                var errorMessages = ex.EntityValidationErrors
                                    .SelectMany(x => x.ValidationErrors)
                                    .Select(x => x.ErrorMessage);

                // Join the list to a single string.
                var fullErrorMessage = string.Join("; ", errorMessages);

                return(fullErrorMessage.ToString());
            }
        }
Exemplo n.º 4
0
        public DataTable Get(proyectos_involucrados entidad)
        {
            DataTable dt = new DataTable();

            try
            {
                Model context = new Model();
                var   query   = context.proyectos_involucrados
                                .Where(s => s.id_pinvolucrado == entidad.id_pinvolucrado & s.usuario_borrado == null)
                                .Select(u => new
                {
                    u.id_pinvolucrado,
                    u.id_proyecto,
                    u.celular,
                    u.id_rol,
                    u.nombre,
                    u.no_empleado,
                    u.telefono,
                    u.correo,
                    u.usuario,
                    u.fecha_registro,
                    u.usuario_edicion,
                    u.fecha_edicion,
                    u.usuario_borrado,
                    u.fecha_borrado,
                    u.comentarios_borrado
                });
                dt = To.DataTable(query.ToList());
                dt.Columns.Add("rol");
                foreach (DataRow row in dt.Rows)
                {
                    roles_proyecto entidadrol = new roles_proyecto();
                    entidadrol.id_rol = Convert.ToInt32(row["id_rol"]);
                    RolesCOM  roles    = new RolesCOM();
                    DataTable dt_roles = roles.Get(entidadrol);
                    if (dt_roles.Rows.Count > 0)
                    {
                        row["rol"] = dt_roles.Rows[0]["rol"].ToString();
                    }
                }
                return(dt);
            }
            catch (Exception ex)
            {
                return(dt);
            }
        }