public int Contar(Expression <Func <T, bool> > where)
 {
     using (var db = new AplicacionDBContext())
     {
         return(db.Set <T>().Where(where).Count());
     }
 }
 public T ObtenerPorId(int id)
 {
     using (var db = new AplicacionDBContext())
     {
         return(db.Set <T>().FirstOrDefault(x => x.Id == id));
     }
 }
 public void Agregar(T entidad)
 {
     using (var db = new AplicacionDBContext())
     {
         db.Entry(entidad).State = System.Data.Entity.EntityState.Added;
         db.SaveChanges();
     }
 }
 public void Eliminar(int id)
 {
     using (var db = new AplicacionDBContext())
     {
         var entidad = new T()
         {
             Id = id
         };
         db.Entry(entidad).State = System.Data.Entity.EntityState.Deleted;
         db.SaveChanges();
     }
 }
        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;
            using (AplicacionDBContext db = new AplicacionDBContext())
            {
                if (orderByClass.IsAscending)
                {
                    return(db.Set <T>().Where(where).OrderBy(orderByClass.OrderBy)
                           .Skip((parametrosDeQuery.Pagina - 1) * parametrosDeQuery.Top)
                           .Take(parametrosDeQuery.Top).ToList());
                }
                else
                {
                    return(db.Set <T>().Where(where).OrderByDescending(orderByClass.OrderBy)
                           .Skip((parametrosDeQuery.Pagina - 1) * parametrosDeQuery.Top)
                           .Take(parametrosDeQuery.Top).ToList());
                }
            }
        }
 public ClienteQueryServicio(AplicacionDBContext context)
 {
     _context = context;
 }
Esempio n. 7
0
 public ProductoQueryServicio(AplicacionDBContext context)
 {
     _context = context;
 }
Esempio n. 8
0
 public ClienteCrearEventHandler(AplicacionDBContext context)
 {
     _context = context;
 }
Esempio n. 9
0
 public UsuarioRepositorio(AplicacionDBContext _db, IMapper _mapper)
 {
     db     = _db;
     mapper = _mapper;
 }
 public TerciarizacionRepositorio(AplicacionDBContext _db, IMapper _mapper)
 {
     db     = _db;
     mapper = _mapper;
 }
 public ProductoEnStockActualizarEventHandler(AplicacionDBContext context,
                                              ILogger <ProductoEnStockActualizarEventHandler> logger)
 {
     _context = context;
     _logger  = logger;
 }
 public ProveedorRepositorio(AplicacionDBContext _db, IMapper _mapper)
 {
     db     = _db;
     mapper = _mapper;
 }
 public ProductoCrearEventHandler(AplicacionDBContext context)
 {
     _context = context;
 }