Ejemplo n.º 1
0
 public List <Product> GetProducts(decimal minKey, decimal maxKey)
 {
     using (BtkAkademiContext context = new BtkAkademiContext())
     {
         return(context.Products.Where(x => x.UnitPrice >= minKey && x.UnitPrice <= maxKey).ToList());
     }
 }
Ejemplo n.º 2
0
 public List <Product> GetProducts(string key)
 {
     using (BtkAkademiContext context = new BtkAkademiContext())
     {
         return(context.Products.Where(x => x.Name.Contains(key)).ToList());
     }
 }
Ejemplo n.º 3
0
 public Product GetProducts(int id)
 {
     using (BtkAkademiContext context = new BtkAkademiContext())
     {
         return(context.Products.SingleOrDefault(x => x.Id == id));
     }
 }
Ejemplo n.º 4
0
 public List <Product> GetProducts()
 {
     using (BtkAkademiContext context = new BtkAkademiContext())
     {
         return(context.Products.ToList());
     }
 }
Ejemplo n.º 5
0
 public void Update(Product product)
 {
     using (BtkAkademiContext context = new BtkAkademiContext())
     {
         //var entity gönderilen bilgilerdeki product'ı veritabanında bulur
         context.Entry(product).State = EntityState.Modified; // bulunan nesneyi modifiye eder
         context.SaveChanges();
     }
 }
Ejemplo n.º 6
0
 public void Delete(Product product)
 {
     using (BtkAkademiContext context = new BtkAkademiContext())
     {
         //var entity gönderilen bilgilerdeki product'ı veritabanında bulur
         var entity = context.Entry(product);
         entity.State = EntityState.Deleted; // bulunan nesneyi siler
         context.SaveChanges();
     }
 }
Ejemplo n.º 7
0
 public void Add(Product product)
 {
     using (BtkAkademiContext context = new BtkAkademiContext())
     {
         /*
          * //var entity gönderilen bilgilerdeki product'ı veritabanında bulur
          * var entity = context.Entry(product);
          * entity.State = EntityState.Added; // gönderilen nesneyi ekler
          */
         context.Products.Add(product);
         context.SaveChanges();
     }
 }