public bool Delete(int id) { if (id == default) { return(false); } var comand = $"DELETE FROM TbCliente WHERE IDCLIENTE = '{id}'"; return(_dal.Delete(comand)); }
public void Delete(Cliente o) { using (var dal = DatabaseConnection.GetDataAccessLayer()) { var dao = new ClienteDal(dal); try { dao.Delete(o); } catch (Exception ex) { throw ex; } } }
public JsonResult ExcluirCliente(int id) { try { ClienteDal d = new ClienteDal(); Cliente c = d.FindById(id); //buscar o cliente pelo id.. //excluindo.. d.Delete(c); return(Json("Cliente " + c.Nome + ", excluido com sucesso.")); } catch (Exception e) { return(Json("Erro ao excluir Cliente: " + e.Message)); } }
public ActionResult Exclusao(int id) { try { ClienteDal d = new ClienteDal(); Cliente cliente = d.FindById(id); d.Delete(cliente); ViewBag.Mensagem = $"Cliente {cliente.Nome} Excluido com sucesso"; } catch (Exception erro) { ViewBag.Mensagem = erro.Message; } return(RedirectToAction("Consulta")); }
//Ação para excluir um cliente selecionado.. // GET: /Cliente/Exclusao/id public ActionResult Exclusao(int id) { try { ClienteDal d = new ClienteDal(); //persistencia.. //buscar o cliente pelo id.. Cliente c = d.FindById(id); //excluir o cliente d.Delete(c); ViewBag.Mensagem = "Cliente " + c.Nome + ", excluido com sucesso."; } catch (Exception e) { //imprimir mensagem de erro.. ViewBag.Mensagem = e.Message; } return(View()); }
public ActionResult Exclusao(int id) { try { ClienteDal d = new ClienteDal(); Cliente c = d.FindById(id); if (c != null) { d.Delete(id); ViewBag.Mensagem = "Cliente " + c.Nome + " excluído com sucesso!"; } else { throw new Exception("Cliente não encontrado."); } } catch (Exception e) { ViewBag.Mensagem = e.Message; } return(View()); }