public int ModificarTipoCliente(tipo_clientes tipo) { try { //Obteniendo el tipo de cliente a modificar tipo_clientes obj = ctx.tipo_clientes.Find(tipo.idtipocliente); if (obj != null) { //Actualizando el valor del objeto ctx.Entry(obj).CurrentValues.SetValues(tipo); ctx.SaveChanges(); return(1); } return(0); } catch (Exception) { return(0); } }
public bool modificar(cliente cliente) { try { //Obteniendo el tipo de cliente a modificar cliente obj = ctx.cliente.Find(cliente.idcliente); if (obj == null) { throw new System.ArgumentException("El cliente no existe", "error"); } //Actualizando el valor del objeto ctx.Entry(obj).CurrentValues.SetValues(cliente); ctx.SaveChanges(); return(true); } catch (Exception) { return(false); } }