public Product GetById(int id) { using (EtradeContext context = new EtradeContext()) { return(context.Products.FirstOrDefault(p => p.Id == id)); } }
public List <Product> ikiFiyatGetir(decimal min, decimal max) { using (EtradeContext context = new EtradeContext()) { return(context.Products.Where(p => p.UnitPrice >= min && p.UnitPrice <= max).ToList()); } }
public List <Product> GetByName(string key) { using (EtradeContext context = new EtradeContext()) { return(context.Products.Where(p => p.Name.Contains(key)).ToList()); } }
public List <Product> GetAll() { using (EtradeContext context = new EtradeContext()) { return(context.Products.ToList()); } }
public void Sil(Product product) { using (EtradeContext context = new EtradeContext()) { var entity = context.Entry(product); entity.State = EntityState.Deleted; context.SaveChanges(); } }
public void Guncelle(Product product) { using (EtradeContext context = new EtradeContext()) { var entity = context.Entry(product); entity.State = EntityState.Modified; context.SaveChanges(); } }