I need to pick up and display a list of client objects by Id

Asked

Viewed 434 times

0

MY CLASS CLIENTEBUS

class ClienteBus:AplicacaoBus<Cliente>
{
    public ClienteBus()
    {
        Tabela = new List<Cliente>();
    }     
}

MY CLIENT CLASS

class Cliente:Entity
{
    private static int _Id;
    public Cliente()
    {
        _Id++;
        Id = _Id;
    }

    protected string nome;
    public string Nome
    {
        get { return nome; }
        set { nome = value; }
    }

    protected string codigo;
    public string Codigo
    {
        get { return codigo; }
        set { codigo = value; }
    }


}

MY APPLICATION CLASS

public class AplicacaoBus<T> where T : Entity
{
    private List<T> tabela;
    public List<T> Tabela
    {
        get { return tabela; }
        set { tabela = value; }
    }

    public void Add(T entity)
    {
        tabela.Add(entity);          
    }

    public Entity LocalizarPorId(int id)
    {

        return Tabela.Where(x => x.Id == id).FirstOrDefault();

    }
}

MAINWINDOW.XML.CS DON’T KNOW HOW TO DO

private void bExibir_Click(object sender, RoutedEventArgs e)
    {
        var posCliente = cliBus.LocalizarPorId(cliente.Id);


        //foreach (var item in cliBus.LocalizarPorId(cliente.Id)) //percorre a collection e atribuindo a item cada valor
      //  {
      //      MessageBox.Show(item);
      //  }

    }
  • Dude, I don’t know if I understand very well what you want to do, but maybe it wouldn’t be a good idea for you to throw your clients on a Hashmap and then yes you would do the ordering according to the desired Id.

  • The posCliente should already be what you want

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.