public JsonResult Delete(int id = 0)
        {
            bool result = false;

            try
            {
                Brand brand = _brandBll.Get(id);
                result = _brandBll.Remove(brand);

                return(Json(result, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                return(Json(ex, JsonRequestBehavior.AllowGet));
            }
        }
Beispiel #2
0
        private void buttonRemoveBrand_Click(object sender, EventArgs e)
        {
            //This method compares the identity of the brand to be deleted with the brand identities in the products database.
            //If there is a product with the identity of the brand to be deleted, the brand cannot be deleted.
            var BrandHasProduct = db.Product.Where(x => x.BrandsId == selectedBrand.Id).FirstOrDefault();

            if (BrandHasProduct != null)
            {
                MessageBox.Show("BU MARKANIN İÇİNDE ÜRÜN MEVCUT BU NEDENLE SİLİNEMEZ!", "Hata", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                brandBussiness.Remove(selectedBrand);
                MessageBox.Show("MARKA SİLİNDİ.", "Bilgilendirme", MessageBoxButtons.OK, MessageBoxIcon.Information);
                getBrands();
            }
        }