I have a DTO called ListaAvdArquivoPagamentoDetDTO.
public class ListaAvdArquivoPagamentoDetDTO
{
public List<AvdArquivoPagamentoDet> AvdArquivoPagamentoDets { get; set;}
public decimal TotalNfsLancadas { get; set;}
}
I made a method to retrieve data and make a new instance of my DTO, however everrything is working good till we reach "listaAvdArquivoPagamentoDet.AvdArquivoPagamentoDets.AddRange(listaPagamentoDet);", when we reach that line the new exception error ocurs.
public ListaAvdArquivoPagamentoDetDTO listarAvdArquivoPagamentoDet(DadosAmbiente amb, int codigoAvdArquivoPagamento)
{
var listaAvdArquivoPagamentoDet = new ListaAvdArquivoPagamentoDetDTO();
InserirListaDeAvdArquivoPagamentoDet(listaAvdArquivoPagamentoDet, amb, codigoAvdArquivoPagamento);
InserirValorTotalNfs(listaAvdArquivoPagamentoDet, amb, codigoAvdArquivoPagamento);
return listaAvdArquivoPagamentoDet;
}
public void InserirListaDeAvdArquivoPagamentoDet(ListaAvdArquivoPagamentoDetDTO listaAvdArquivoPagamentoDet, DadosAmbiente amb, int codigoAvdArquivoPagamento)
{
var listaPagamentoDet = _repAvdArquivoPagamentoDet.Recuperar().Where(p => p.CodigoArquivo == codigoAvdArquivoPagamento &&
p.CodigoEmpresa == amb.idEmpresa).ToList();
if(listaPagamentoDet == null)
{
return;
}
listaAvdArquivoPagamentoDet.AvdArquivoPagamentoDets.AddRange(listaPagamentoDet);
}
I tried a cople of things, I expect to amake it work using the most I can from Clean Code principles.