//PROCEDIMEINTO ALMACENADO PARA HACER CONSULTA DE HARWARE DETALLE CON PARAMETROS public virtual List <HardwareInfo> GetHardwareDetail(int idhardware = 0) { var ctx = new ProyectoContext(); SqlParameter param1 = new SqlParameter("@idhardware", idhardware); return(ctx.Database.SqlQuery <HardwareInfo>("SP_NSUITE_hardware_Select @idhardware", param1).ToList()); }
public ResponseModel Guardar() { var rm = new ResponseModel(); try { using (var ctx = new ProyectoContext()) { if (this.id > 0) { ctx.Entry(this).State = EntityState.Modified; } else { ctx.Entry(this).State = EntityState.Added; } ctx.SaveChanges(); rm.SetResponse(true); } } catch (Exception) { throw; } return(rm); }
public virtual List <ReportingNumOrden> GetRPT_numeroorden_por_id(int idorden) { var ctx = new ProyectoContext(); SqlParameter param1 = new SqlParameter("@idorden", idorden); return(ctx.Database.SqlQuery <ReportingNumOrden>("RPT_orden_por_id @idorden", param1).ToList()); }
public Usuario Obtener(int id, bool includes = false) { var usuario = new Usuario(); try { using (var ctx = new ProyectoContext()) { if (!includes) { usuario = ctx.Usuario.Where(x => x.id == id) .SingleOrDefault(); } else { usuario = ctx.Usuario.Include("Experiencia") .Include("Habilidad") .Include("Testimonio") .Where(x => x.id == id) .SingleOrDefault(); } // Trayendo un registro adicional de manera manual, sin usar Include usuario.Pais = new TablaDato().Obtener("pais", usuario.Pais_id.ToString()); } } catch (Exception) { throw; } return(usuario); }
public Usuario Obtener(int id, bool includes = false) { var usuario = new Usuario(); try { using (var ctx = new ProyectoContext()) { if (!includes) { usuario = ctx.Usuario.Where(x => x.id == id).SingleOrDefault(); } else { usuario = ctx.Usuario.Include("Experiencia") .Include("Habilidad") .Include("Testimonio") .Where(x => x.id == id).SingleOrDefault(); } } } catch (Exception) { throw; } return(usuario); }
//PARA HACER MODIFICACION DEL PERFIL //public int Conteo() //{ // using (var ctx = new ProyectoContext()) // { // return ctx.Usuario.Count(); // } //} public ResponseModel Acceder(string cuenta, string clave) { var rm = new ResponseModel(); try { using (var ctx = new ProyectoContext()) { clave = HashHelper.MD5(clave); var usuario = ctx.Usuario.Where(x => x.cuenta == cuenta) .Where(x => x.clave == clave) .SingleOrDefault(); if (usuario != null) { SessionHelper.AddUserToSession(usuario.idusuario.ToString()); rm.SetResponse(true); } else { rm.SetResponse(false, "cuenta o contraseña incorrecta"); } } } catch (Exception) { throw; } return(rm); }
public ResponseModel Eliminar(int id) { var rm = new ResponseModel(); try { using (var ctx = new ProyectoContext()) { if (id > 0) { this.id = id; ctx.Entry(this).State = EntityState.Deleted; ctx.SaveChanges(); rm.SetResponse(true); } } } catch (Exception e) { throw e; } return(rm); }
public Usuario ObtenerPerfil(int id, bool includes = false) { var usuario = new Usuario(); try { using (var ctx = new ProyectoContext()) { if (!includes) { usuario = ctx.Usuario.Where(x => x.idusuario == id) .SingleOrDefault(); } else { usuario = ctx.Usuario.Where(x => x.idusuario == id) .SingleOrDefault(); } // Extraendo y Agregando El Cmapo Empresa //usuario.miempresa = new Empresa().ObtenerEmpresa(id, usuario.Empresa_Id.ToString()); } } catch (Exception ex) { string errorusuario = ex.Message; throw; } return(usuario); }
public virtual List <MesSinOS> get_ListarOrdenesSinMes() { using (var ctx = new ProyectoContext()) { return(ctx.Database.SqlQuery <MesSinOS>("RRR_Select_Procesos_sin_mes_asignado").ToList()); } }
//VISTA PARA CLIENTES DE PROCESOS Y EQUIPOS ACTIVOS public virtual List <Reporting> GetRPT_Hardware_produccion_for_empresa(string empresa) { var ctx = new ProyectoContext(); SqlParameter param1 = new SqlParameter("@empresa", empresa); return(ctx.Database.SqlQuery <Reporting>("RPT_Hardware_produccion_for_empresa @empresa", param1).ToList()); }
public int Conteo() { using (var ctx = new ProyectoContext()) { return(ctx.TablaDato.Count()); } }
//PARA BUSCAR EN VISTA PARCIAL INVENTARIO LOS USUARIOS FINALES DEL EQUIPO POR EL ORDEN ID. public virtual List <Reporting> Get_usuario_final_host(int id) { var ctx = new ProyectoContext(); SqlParameter param1 = new SqlParameter("@idordenuser", id); return(ctx.Database.SqlQuery <Reporting>("SP_RPT_BUSCARUSUARIOFINAL @idordenuser", param1).ToList()); }
public virtual List <Reporting> GetRPT_Hardware_produccion() { var ctx = new ProyectoContext(); // SqlParameter param1 = new SqlParameter("@idhardware", idhardware); return(ctx.Database.SqlQuery <Reporting>("RPT_Hardware_produccion").ToList()); }
public ResponseModel Acceder(string Email, string Password) { var rm = new ResponseModel(); try { using (var ctx = new ProyectoContext()) { Password = HashHelper.MD5(Password); var usuario = ctx.Usuario.Where(x => x.Email == Email) .Where(x => x.Password == Password) .SingleOrDefault(); if (usuario != null) { SessionHelper.AddUserToSession(usuario.id.ToString()); rm.SetResponse(true); } else { rm.SetResponse(false, "Correo o contraseña incorrecta"); } } } catch (Exception) { throw; } return(rm); }
public Usuario Obtener(int id, bool includes = false) { var usuario = new Usuario(); try { using (var ctx = new ProyectoContext()) { if (!includes) { usuario = ctx.Usuario.Where(x => x.id == id) .SingleOrDefault(); } else { usuario = ctx.Usuario.Include("Experiencia") .Include("Habilidad") .Include("Testimonio") .Where(x => x.id == id) .SingleOrDefault(); } //esta es la forma de traer datos de tablas no relacionadas. usuario.Pais = new TablaDato().Obtener("pais", usuario.Pais_id.ToString()); } } catch (Exception) { throw; } return(usuario); }
public virtual List <Liquidacion> RRR_Liquidacion_mensual(string usuarioEjecutoo) { var ctx = new ProyectoContext(); SqlParameter param1 = new SqlParameter("@usuarioEjecuto", usuarioEjecutoo); return(ctx.Database.SqlQuery <Liquidacion>("RRR_insert_liquidacion @usuarioEjecuto", param1).ToList()); }
public ResponseModel Guardar() { var rm = new ResponseModel(); Servicio serv = new Servicio(); try { using (var ctx = new ProyectoContext()) { if (this.idservicio > 0) { ctx.Entry(this).State = EntityState.Modified; } else { ctx.Entry(this).State = EntityState.Added; //var idultimo = } rm.SetResponse(true); ctx.SaveChanges(); } } catch (Exception E) { throw; } return(rm); }
public AnexGRIDResponde Listar(AnexGRID grid, int tipo, int Usuario_id) { try { using (var ctx = new ProyectoContext()) { ctx.Configuration.LazyLoadingEnabled = false; grid.Inicializar(); var query = ctx.Experiencia.Where(x => x.Tipo == tipo) .Where(x => x.Usuario_id == Usuario_id); if (grid.columna == "id") { query = grid.columna_orden == "DESC" ? query.OrderByDescending(x => x.id) : query.OrderBy(x => x.id); } if (grid.columna == "Nombre") { query = grid.columna_orden == "DESC" ? query.OrderByDescending(x => x.Nombre) : query.OrderBy(x => x.Nombre); } if (grid.columna == "Titulo") { query = grid.columna_orden == "DESC" ? query.OrderByDescending(x => x.Titulo) : query.OrderBy(x => x.Nombre); } if (grid.columna == "Desde") { query = grid.columna_orden == "DESC" ? query.OrderByDescending(x => x.Desde) : query.OrderBy(x => x.Desde); } if (grid.columna == "Hasta") { query = grid.columna_orden == "DESC" ? query.OrderByDescending(x => x.Hasta) : query.OrderBy(x => x.Hasta); } var experiencias = query.Skip(grid.pagina) .Take(grid.limite) .ToList(); var total = query.Count(); grid.SetData(experiencias, total); } } catch (Exception) { throw; } return(grid.responde()); }
public virtual List <Facturacion> Get_factuacion(string mes, string empresa) { var ctx = new ProyectoContext(); //SqlParameter param1 = new SqlParameter("@MES", mes); //SqlParameter param2 = new SqlParameter("@EMPRESA", empresa); return(ctx.Database.SqlQuery <Facturacion>("Rpt_detalle_facturacion @MES, @EMPRESA", new Object[] { new SqlParameter("@MES", mes), new SqlParameter("@EMPRESA", empresa) }).ToList()); }
public AnexGRIDResponde Listar(AnexGRID grid, int tipo, int usuario_id) { try { using (var ctx = new ProyectoContext()) { ctx.Configuration.LazyLoadingEnabled = false; grid.Inicializar(); var query = ctx.Experiencia.Where(x => x.tipo == tipo).Where(x => x.usuario_id == usuario_id); //expresión lambda //sintaxis de una expresión lambda (parameters)=>expression-or-statement-block //ej: x=>x*x //ordenamiento //id, titulo, desde, hasta if (grid.columna == "id") { query = grid.columna_orden == "DESC" ? query.OrderByDescending(x => x.id) : query.OrderBy(x => x.id); } if (grid.columna == "nombre") { query = grid.columna_orden == "DESC" ? query.OrderByDescending(x => x.nombre) : query.OrderBy(x => x.nombre); } if (grid.columna == "titulo") { query = grid.columna_orden == "DESC" ? query.OrderByDescending(x => x.titulo) : query.OrderBy(x => x.titulo); } if (grid.columna == "desde") { query = grid.columna_orden == "DESC" ? query.OrderByDescending(x => x.desde) : query.OrderBy(x => x.desde); } if (grid.columna == "hasta") { query = grid.columna_orden == "DESC" ? query.OrderByDescending(x => x.hasta) : query.OrderBy(x => x.hasta); } var experiencias = query.Skip(grid.pagina).Take(grid.limite).ToList(); var total = query.Count(); grid.SetData(experiencias, total); } } catch (Exception E) { throw; } return(grid.responde()); }
public ResponseModel Guardar(HttpPostedFileBase Foto) { var rm = new ResponseModel(); try { using (var ctx = new ProyectoContext()) { //validaciones esten desabilitadas ctx.Configuration.ValidateOnSaveEnabled = false; var eUsuario = ctx.Entry(this); eUsuario.State = EntityState.Modified; //Campos que queremos ignorar if (this.Foto != null) { //Nombre del archivo, es decir, lo renombramos para que no se repita nunca string archivo = DateTime.Now.ToString("yyyyMMddHHmmss") + Path.GetExtension(Foto.FileName); //Ruta donde lo vamos a guardar Foto.SaveAs(HttpContext.Current.Server.MapPath("~/uploads/" + archivo)); //Establecemos en nuestro modelo el nombre del archivo this.Foto = archivo; } else { eUsuario.Property(x => x.Foto).IsModified = false; } if (this.Password == null) { eUsuario.Property(x => x.Password).IsModified = false; } ctx.SaveChanges(); rm.SetResponse(true); } } catch (DbEntityValidationException) { throw; } catch (Exception) { throw; } return(rm); }
public AnexGRIDResponde Listar(AnexGRID grid, int Usuario_id) { try { using (var ctx = new ProyectoContext()) { ctx.Configuration.LazyLoadingEnabled = false; grid.Inicializar(); var query = ctx.Testimonio.Where(x => x.Usuario_id == Usuario_id); // Ordenamiento if (grid.columna == "id") { query = grid.columna_orden == "DESC" ? query.OrderByDescending(x => x.id) : query.OrderBy(x => x.id); } if (grid.columna == "Nombre") { query = grid.columna_orden == "DESC" ? query.OrderByDescending(x => x.Nombre) : query.OrderBy(x => x.Nombre); } if (grid.columna == "IP") { query = grid.columna_orden == "DESC" ? query.OrderByDescending(x => x.IP) : query.OrderBy(x => x.IP); } if (grid.columna == "Fecha") { query = grid.columna_orden == "DESC" ? query.OrderByDescending(x => x.Fecha) : query.OrderBy(x => x.Fecha); } var Testimonios = query.Skip(grid.pagina) .Take(grid.limite) .ToList(); var total = query.Count(); grid.SetData(Testimonios, total); } } catch (Exception E) { throw; } return(grid.responde()); }
public void Eliminar() { try { using (var ctx = new ProyectoContext()) { ctx.Entry(this).State = EntityState.Deleted; ctx.SaveChanges(); } } catch (Exception E) { throw; } }
public AnexGRIDResponde Listar(AnexGRID grid, int Usuario_id) { try { using (var ctx = new ProyectoContext()) { ctx.Configuration.LazyLoadingEnabled = false; grid.Inicializar(); var query = ctx.Habilidad.Where(x => x.Usuario_id == Usuario_id); // Ordenamiento if (grid.columna == "id") { query = grid.columna_orden == "DESC" ? query.OrderByDescending(x => x.id) : query.OrderBy(x => x.id); } if (grid.columna == "Nombre") { query = grid.columna_orden == "DESC" ? query.OrderByDescending(x => x.Nombre) : query.OrderBy(x => x.Nombre); } if (grid.columna == "Dominio") { query = grid.columna_orden == "DESC" ? query.OrderByDescending(x => x.Dominio) : query.OrderBy(x => x.Dominio); } // id, Nombre, Titulo, Desde, Hasta var experiencias = query.Skip(grid.pagina) .Take(grid.limite) .ToList(); var total = query.Count(); grid.SetData(experiencias, total); } } catch (Exception E) { throw; } return(grid.responde()); }
//Para HttpPostedFileBase: Se agrego Proyecto Model la referencia desde Assembly Sysmtem.Web public ResponseModel Guardar(HttpPostedFileBase Foto, String Password) { ResponseModel rm = new ResponseModel(); try { using (var ctx = new ProyectoContext()) { ctx.Configuration.ValidateOnSaveEnabled = false; var usr = ctx.Entry(this); usr.State = EntityState.Modified; if (this.Foto != null) { string archivo = DateTime.Now.ToString("yyyyMMddHHmmss") + Path.GetExtension(Foto.FileName); Foto.SaveAs(HttpContext.Current.Server.MapPath("~/Uploads" + archivo)); this.Foto = archivo; } else { usr.Property(x => x.Foto).IsModified = false; } if (this.Password == null) { usr.Property(x => x.Password).IsModified = false; } else { this.Password = Helper.HashHelper.MD5(Password); } ctx.SaveChanges(); rm.SetResponse(true); } } catch (DbEntityValidationException e) { throw e; } catch (Exception e) { throw e; } return(rm); }
public Experiencia Obtener(int id) { var experiencia = new Experiencia(); try { using (var ctx = new ProyectoContext()){ experiencia = ctx.Experiencia.Where(x => x.id == id) .SingleOrDefault(); } } catch (Exception) { throw; } return(experiencia); }
public Habilidad Obtener(int id) { var habilidad = new Habilidad(); try { using (var ctx = new ProyectoContext()) { habilidad = ctx.Habilidad.Where(x => x.id == id) .SingleOrDefault(); } } catch (Exception) { throw; } return(habilidad); }
//para lado CLIENTE public List <CatalogoPrecios> ListarCatalogoPorEmpresaTipo(string nombreempresa, string tipo) { var catalogo = new List <CatalogoPrecios>(); try { using (var ctx = new ProyectoContext()) { catalogo = ctx.CatalogoPrecios.Where(p => p.empresa == nombreempresa && p.nombre == tipo).ToList(); } } catch (Exception E) { throw; } return(catalogo); }
public Testimonio Obtener(int id) { var Testimonio = new Testimonio(); try { using (var ctx = new ProyectoContext()) { Testimonio = ctx.Testimonio.Where(x => x.id == id) .SingleOrDefault(); } } catch (Exception) { throw; } return(Testimonio); }
public List <Orden> ListarOrden() { var listaorden = new List <Orden>(); try { using (var ctx = new ProyectoContext()) { listaorden = ctx.Orden.ToList(); } } catch (Exception) { throw; } return(listaorden); }