public int Contar(Expression <Func <T, bool> > where) { using (var db = new AplicacionDbContext()) { return(db.Set <T>().Where(where).Count()); } }
public JsonResult BuscaPersonas(string term) { AplicacionDbContext db = new AplicacionDbContext(); var resultado = db.Personas.Where(x => x.Nombre.Contains(term)).ToList(); return(Json(resultado, JsonRequestBehavior.AllowGet)); }
public ActionResult Index() { AplicacionDbContext db = new AplicacionDbContext(); ////var persona1 = new Persona() { Nombre = "Edwin", Edad = 29 }; ////var persona2 = new Persona() { Nombre = "Omar", Edad = 26 }; //var persona3 = new Persona() { Nombre = "Frankely", Edad = 21 }; //var persona4 = new Persona() { Nombre = "Rossi", Edad = 28 }; //var persona6 = new Persona() {Id=6, Nombre = "Deivi", Edad = 29 }; ////var persona2 = db.Personas.Where(x => x.Id == 2).FirstOrDefault(); //db.Personas.Add(persona3); //db.Personas.Add(persona4); //db.Personas.Add(persona5); //db.SaveChanges(); //var detalle6 = new DetallePersona() { Peso = 150, Altura = 5.8,Sexo="Femenino",Persona=persona6}; ////var detalle4 = new DetallePersona() { Peso = 160, Altura = 5.8,Sexo="Masculino", Persona = persona4 }; ////var detalle5 = new DetallePersona() { Peso = 170, Altura = 5.11, Sexo = "Masculino", Persona = persona5 }; ////db.DetallePersonas.Add(detalle3); ////db.DetallePersonas.Add(detalle4); //db.DetallePersonas.Add(detalle6); //db.SaveChanges(); //var personas = db.Personas.Include("Detalle").ToList(); return(View()); }
public PartialViewResult CargarSeccion() { AplicacionDbContext db = new AplicacionDbContext(); var personas = db.Personas.Include("Detalle").ToList(); return(PartialView("_Prueba", personas)); }
public PartialViewResult DetallePersona(int PersonaId) { AplicacionDbContext db = new AplicacionDbContext(); var PersonaDetalles = db.DetallePersonas.Where(x => x.PersonaId == PersonaId).FirstOrDefault(); return(PartialView("_DetallePersona", PersonaDetalles)); //return PartialView(); }
public void Actualizar(T tabla) { using (var db = new AplicacionDbContext()) { tabla.FechaModificacion = DateTime.Now; db.Entry(tabla).State = EntityState.Modified; db.SaveChanges(); } }
public void Agregar(T tabla) { using (var db = new AplicacionDbContext()) { tabla.FechaCreacion = DateTime.Now; db.Entry(tabla).State = System.Data.Entity.EntityState.Added; db.SaveChanges(); } }
public JsonResult BusquedaRapida(string term) { using (AplicacionDbContext db = new AplicacionDbContext()) { var resultado = db.localidades.Where(x => x.Nombre.Contains(term)).OrderBy(x => x.Nombre) .Select(x => x.Nombre).Take(5).ToList(); return(Json(resultado, JsonRequestBehavior.AllowGet)); } }
public T ObtenerPorId(int id, ParametrosDeQuery <T> parametrosDeQuery) { var include = (parametrosDeQuery.Include); using (var db = new AplicacionDbContext()) { return(db.Set <T>().Include(include).FirstOrDefault(x => x.Id == id)); } }
public void Eliminar(int id) { using (var db = new AplicacionDbContext()) { var tabla = new T() { Id = id }; db.Entry(tabla).State = System.Data.Entity.EntityState.Deleted; db.SaveChanges(); } }
public IEnumerable <SelectListItem> ObtenerListado() { using (AplicacionDbContext db = new AplicacionDbContext()) { List <SelectListItem> c_provincias = db.provincias.AsNoTracking() .OrderBy(n => n.Nombre) .Select(n => new SelectListItem { Value = n.Id.ToString(), Text = n.Nombre }).ToList(); //var nuevo = new SelectListItem() //{ // Value = null, // Text = "" //}; //c_provincias.Insert(0, nuevo); return(new SelectList(c_provincias, "Value", "Text")); } }
public IEnumerable <T> EncontrarPor(ParametrosDeQuery <T> parametrosDeQuery) { var orderByClass = ObtenerOrderBy(parametrosDeQuery); Expression <Func <T, bool> > whereTrue = x => true; var where = (parametrosDeQuery.Where == null) ? whereTrue : parametrosDeQuery.Where; var include = (parametrosDeQuery.Include); using (AplicacionDbContext db = new AplicacionDbContext()) { if (orderByClass.IsAscending) { return(db.Set <T>().Include(include).Where(where).OrderBy(orderByClass.OrderBy) .Skip((parametrosDeQuery.Pagina - 1) * parametrosDeQuery.Top) .Take(parametrosDeQuery.Top).ToList()); } else { return(db.Set <T>().Include(include).Where(where).OrderByDescending(orderByClass.OrderBy) .Skip((parametrosDeQuery.Pagina - 1) * parametrosDeQuery.Top) .Take(parametrosDeQuery.Top).ToList()); } } }
public PersonaController(AplicacionDbContext contexto) { _context = contexto; }
public InventarioBicicletaRepository(AplicacionDbContext db) : base(db) { }
public ProductosRepositorio(AplicacionDbContext context) { this._contexto = context; }
public RegistroVentaRepository(AplicacionDbContext db) : base(db) { }
public InventarioRepositorio(AplicacionDbContext context) { this._contexto = context; }
public FacturasController(AplicacionDbContext context) { _context = context; }
public AutoesController(AplicacionDbContext context) { _context = context; }
public SexoController(AplicacionDbContext contexto) { _context = contexto; }
public static async Task InsertDatosEjemplo(AplicacionDbContext context) { if (!context.Bodegas.Any()) { List <Bodega> bodegasDefault = new List <Bodega> { new Bodega { Id = Guid.Parse("40e05749-8b35-42c3-b68e-1232da850baf"), Nombre = "Bodega 1", Descripcion = "Bodega de prueba 1", Ubicacion = "Ubicacion 1", CapacidadMaxima = 100 }, new Bodega { Id = Guid.Parse("03d734ad-4bd8-444f-b9dd-d497d1fa3974"), Nombre = "Bodega 2", Descripcion = "Bodega de prueba 2", Ubicacion = "Ubicacion 1", CapacidadMaxima = 150 }, new Bodega { Id = Guid.Parse("460f54b0-0555-4ae5-a119-47cffd8b5d33"), Nombre = "Bodega 3", Descripcion = "Bodega de prueba 3", Ubicacion = "Ubicacion 2", CapacidadMaxima = 200 } }; context.Bodegas.AddRange(bodegasDefault); } if (!context.Productos.Any()) { List <Producto> productosDefault = new List <Producto> { new Producto { Id = Guid.Parse("d73b1452-fc54-4920-a796-a10f25b48715"), Nombre = "Producto de prueba 1", Descripcion = "Esto es un producto de prueba 1", sku = "PRO-PRU-1" }, new Producto { Id = Guid.Parse("9ae171ea-c81a-454c-8dd8-c5d0ca433f5c"), Nombre = "Producto de prueba 2", Descripcion = "Esto es un producto de prueba 2", sku = "PRO-PRU-2" }, new Producto { Id = Guid.Parse("81eafc34-4146-468b-b830-30010ed840f6"), Nombre = "Producto de prueba 3", Descripcion = "Esto es un producto de prueba 3", sku = "PRO-PRU-3" } }; context.Productos.AddRange(productosDefault); } await context.SaveChangesAsync(); }
public ProgramadorController(AplicacionDbContext context) { _context = context; }
public TipoIdentificacionController(AplicacionDbContext contexto) { _context = contexto; }
public BodegaRepositorio(AplicacionDbContext context) { this._contexto = context; }
public ClienteRepository(AplicacionDbContext db) : base(db) { }
public LibroRepositorio(AplicacionDbContext db, IMapper mapper) { _db = db; _mapper = mapper; }
public ClienteController(AplicacionDbContext context) { _context = context; }