They asked me this question: What is OLTP? I ran home, opened google and started to "goolgar", so I came across these codes, which are said to have problems in OLTP environments and I do not understand bullying:
public JsonResult ListarAlocacoes(AlocacaoView alocacaoView)
{
var contratosAlocacaoList = ObterContratosAlocacao(alocacaoView);
/* ... */
}
private IList<AlocacaoJson> ObterContratosAlocacao(AlocacaoView alocacaoView = null)
{
var contratoList = BaseContext.DbContext.Set<Contrato>().Include("ContratoValores").ToList();
foreach (var contrato in contratoList.Where( /* ... */ ))
{
var alocacao = MontarAlocacao(contrato, alocacaoView.CompetenciaId);
/* ... */
}
/* ... */
}
private AlocacaoJson MontarAlocacao(Contrato contrato, DateTime dataCompetencia, int? equipeId = null)
{
var alocacao = new AlocacaoJson();
/* ... */
alocacao.Equipe = ObterEquipeContrato(contrato, equipeId);
alocacao.CustoTotal = ObterCustoTotalContrato(contrato, dataCompetencia);
/* ... */
}
private EquipeJson ObterEquipeContrato(Contrato contrato, int? equipeId)
{
var equipe = BaseContext.DbContext.Set<Equipe>().Find(equipeId.Value);
/* ... */
}
private CustoTotalJson ObterCustoTotalContrato(Contrato contrato, DateTime dataCompetencia)
{
var competencia = BaseContext.DbContext.Set<Competencia>().Where(c => c.Data == dataCompetencia).First(); ;
var alocacao = BaseContext.DbContext.Set<Alocacao>().Include("AlocacoesProjeto").Include("Contrato").Include("Equipe").SingleOrDefault(c => c.CompetenciaData == competencia.Data);
var valorHora = BaseContext.DbContext.Set<Funcao>().Find( /* ... */ ).ValoresHoras.SingleOrDefault( /* ... */ );
var custoTotal = (decimal)(valorHora.Valor * alocacao.QtdeHoras) /* ... */;
/* ... */
}
In a production environment would this stick to an OLTP approach? Why?