Esempio n. 1
0
 public List <Product> GetByUnitPrice(decimal min, decimal max)
 {
     using (EtradeContext context = new EtradeContext())
     {
         return(context.Product.Where(p => p.UnitPrice >= min && p.UnitPrice <= max).ToList());
     }
 }
Esempio n. 2
0
 public List <Product> GetByname(String key)
 {
     using (EtradeContext context = new EtradeContext())
     {
         return(context.Product.Where(p => p.Name.Contains(key)).ToList());
     }
 }
Esempio n. 3
0
 public List <Product> GetAll()
 {
     using (EtradeContext context = new EtradeContext())
     {
         return(context.Product.ToList());
     }
 }
Esempio n. 4
0
 public void Add(Product product)
 {
     using (EtradeContext context = new EtradeContext())
     {
         context.Product.Add(product);
         context.SaveChanges();
     }
 }
Esempio n. 5
0
 public Product GetById(int id)
 {
     using (EtradeContext context = new EtradeContext())
     {
         var result = context.Product.FirstOrDefault(p => p.Id == id);
         return(result);
     }
 }
Esempio n. 6
0
        public void Delete(Product product)
        {
            using (EtradeContext context = new EtradeContext())
            {
                var entity = context.Entry(product);
                entity.State = System.Data.Entity.EntityState.Deleted;

                context.SaveChanges();
            }
        }