public ActionResult DeleteBrand(long id) { //Controller untuk proses delete brand //Code: Geraldo brandRepo.Delete(id); return(RedirectToAction("IndexBrand")); }
public async Task DeleteRemovesBrand() { using (var conn = OpenConnection()) { var b = new Brand("Name"); await conn.ExecuteAsync("insert into brands (id, name) values (@Id, @Name);", b); var repo = new BrandRepo(Database); await repo.Delete(b); var count = await conn.QueryFirstAsync <int>("Select count(*) from brands where id = @Id;", b); Assert.AreEqual(0, count); } }
private void btdelete_Click(object sender, EventArgs e) { if (gvbrand.SelectedRows.Count == 0) { MessageBox.Show("Tidak ada brand yang akan dihapus"); } else { //var id = Convert.ToInt32(gvbrand.Rows[gvbrand.CurrentCell.RowIndex].Cells["id"].Value); var selectedRowId = (int)gvbrand.SelectedRows[0].Cells["id"].Value; if (selectedRowId == 1) { MessageBox.Show("Anda tidak dibenarkan menghapus brand Lain-Lain"); } else { ListProducts = productRepo.GetAll(); var product = ListProducts.FirstOrDefault(x => x.brandid == selectedRowId); if (product == null) { var form = new ConfirmationDialog(); form.Message = "Apa anda yakin menghapus brand terpilih?"; form.ShowDialog(); if (form.YES) { if (!brandRepository.Delete(selectedRowId)) { MessageBox.Show("Gagal menghapus brand"); } LoadData(); } } else { MessageBox.Show("Anda tidak dibenarkan menghapus brand yang masih memiliki barang"); } } } }