bool AddProduct(Product prdct)
 {
     using (DbSentekStore dbase = new DbSentekStore())
     {
         dbase.Products.Add(prdct);
         return(dbase.SaveChanges() > 0);
     }
 }
        bool AddCategory(Category category)
        {
            using (DbSentekStore context = new DbSentekStore())
            {
                context.Categories.Add(category);

                return(context.SaveChanges() > 0);
            }
        }
        public void GetCategories()
        {
            using (DbSentekStore context = new DbSentekStore())
            {
                dgvCategories.DataSource = null;
                dgvCategories.DataSource = context.Categories.Select(c => new { KategoriId = c.CategoryId, KategoriAdi = c.CategoryName, Aktiflik = c.IsActive }).ToList();
            }

            dgvCategories.Columns[0].HeaderText = "Kategori Numarası ";
            dgvCategories.Columns[1].HeaderText = "Kategori Adı ";
            dgvCategories.Columns[2].HeaderText = "Aftiflik";
        }
        bool DeleteCategory(int categoryId)
        {
            using (DbSentekStore context = new DbSentekStore())
            {
                if (context.Categories.Any(o => o.CategoryId == categoryId))
                {
                    var catego = context.Categories.Where(c => c.CategoryId == categoryId).First();
                    context.Categories.Remove(catego);
                    MessageBox.Show("Silme İşlemi Gerçekleşti ");

                    return(context.SaveChanges() > 0);
                }
                else
                {
                    MessageBox.Show("Girdiğiniz Numarada Bir Kayıt Yoktur!!");
                    return(true);
                }
            }
        }
        bool DeleteProduct(string productName)
        {
            using (DbSentekStore dbase = new DbSentekStore())
            {
                if (dbase.Products.Any(p => p.ProductName == productName))
                {
                    Product prdcts = dbase.Products
                                     .Where(p => p.ProductName == productName).First();

                    dbase.Products.Remove(prdcts);
                    return(dbase.SaveChanges() > 0);
                }

                else
                {
                    MessageBox.Show("Girdiğiniz ürün numarası bulunmamaktadır!!");
                    return(true);
                }
            }
        }
 void GetProduct()
 {
     using (DbSentekStore dbase = new DbSentekStore())
     {
         dgvProduct.DataSource = null;
         dgvProduct.DataSource = dbase.Products.Select(p =>
                                                       new
         {
             ÜrünNo     = p.ProductId,
             ÜrünAdı    = p.ProductName,
             ÜrünTarihi = p.ProductBuyDate,
             ÜrünAdeti  = p.Quantity,
             ÜrünFiyatı = p.Price,
         }).ToList();
         dgvProduct.Columns[0].HeaderText = "Ürün Numarası ";
         dgvProduct.Columns[1].HeaderText = "Ürün Adı  ";
         dgvProduct.Columns[2].HeaderText = "Ürün Alınış Tarihi ";
         dgvProduct.Columns[3].HeaderText = "Ürün Adeti ";
         dgvProduct.Columns[4].HeaderText = "Ürün Fiyatı ";
     }
 }
        bool UpdateProduct(Product product)
        {
            using (DbSentekStore context = new DbSentekStore())
            {
                if (context.Products.Any(p => p.ProductId == product.ProductId))
                {
                    var prdct = context.Products.First(p => p.ProductId == product.ProductId);

                    prdct.ProductName    = product.ProductName;
                    prdct.ProductBuyDate = product.ProductBuyDate;
                    prdct.Quantity       = product.Quantity;
                    prdct.Price          = product.Price;
                    prdct.IsActive       = product.IsActive;
                    prdct.CategoryId     = product.CategoryId;



                    return(context.SaveChanges() > 0);
                }


                return(true);
            }
        }