I'm trying to make a supply system, I need it to take the last km registered in the bank of a specific vehicle and be subtracted by the new one that will be inserted I'm trying to do this, but it does not show any error, but does not subtract . My Controller:
var teste_01 = ckm.ConsultaVeiculo(viewModel.NumCarroId);
var teste_02 = teste_01.OrderBy(a => a.Km).FirstOrDefault();
viewModel.Km = viewModel.Km - teste_02.Km;
And this is my query:
public IList<Veiculo> ConsultaVeiculo(int Ncarro)
{
string hql = "SELECT v FROM Veiculo v";
IQuery query = session.CreateQuery(hql);
return query.List<Veiculo>();
}