2
My application is divided as follows:
Repository --> Access Progress database
Controller --> Receives Repository return and sends to View
View --> Receives Controller Return.
Next, my Repository is like this :
public Projeto.Model.Projeto ObterProjetoPorEstabCcustoCodigo(Estabelecimento pEstabelecimento, CentroCusto pCentroCusto, Projeto.Model.Projeto pProjeto)
{
using (var pim = new PIM(new infraProgress().buscaBroker(), "", "", ""))
{
pim.pim_busca_projeto_codigo(pEstabelecimento.Sigla, pCentroCusto.Id, pProjeto.Id, out string resumo, out string valPrevisto, out string valAlocado, out string valVariacao, out string valSaldo, out string tipoDeDocumento, out string msg);
var projeto = new Projeto.Model.Projeto()
{
Descricao = resumo,
ValPrevisto = Convert.ToDecimal(valPrevisto),
ValorAlocado = Convert.ToDecimal(valAlocado),
VariacaoLimite = Convert.ToDecimal(valVariacao),
ValorLiberadoGastar = Convert.ToDecimal(valSaldo),
Classificacao = tipoDeDocumento
};
return projeto;
}
}
public Projeto.Model.Projeto ObterProjetoPorEstabCcustoCodigo(Estabelecimento pEstabelecimento, CentroCusto pCentroCusto, Projeto.Model.Projeto pProjeto)
{
using (var pim = new PIM(new infraProgress().buscaBroker(), "", "", ""))
{
pim.pim_busca_projeto_codigo(pEstabelecimento.Sigla, pCentroCusto.Id, pProjeto.Id, out string resumo, out string valPrevisto, out string valAlocado, out string valVariacao, out string valSaldo, out string tipoDeDocumento, out string msg);
var projeto = new Projeto.Model.Projeto()
{
Descricao = resumo,
ValPrevisto = Convert.ToDecimal(valPrevisto),
ValorAlocado = Convert.ToDecimal(valAlocado),
VariacaoLimite = Convert.ToDecimal(valVariacao),
ValorLiberadoGastar = Convert.ToDecimal(valSaldo),
Classificacao = tipoDeDocumento
};
return projeto;
}
}
Notice that the process pim_search_project_code returns the information of my Project object and also an out msg parameter.
That’s my problem, I need to return the object Projeto
and also the msg
.
This is because the msg
returns some error conditions that I need to demonstrate to the user.
I like your idea.
– Anderson Apdo de Souza
In this case I have several routines that go through this kind of problem? How can I create something more generic? In this case, the name of my application is PIM, I could create a Pimmensage template and within this model will add the classes as needed?
– Anderson Apdo de Souza
It depends on the case. If you will always have a model and a message, you can create a generic class that contains a generic object and a string. This way you avoid having to create a class for each model.
– Jéf Bueno
I left an example, @Andersonapdodesouza
– Jéf Bueno
Thank you, thank you very much. Problem solved.
– Anderson Apdo de Souza