0
I want to update on one condition, however, you are updating the data without seeing the if condition
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using BlogWeb.ViewsModels;
using BlogWeb.DAO;
using BlogWeb.Models;
using BlogWeb.Filters;
using BlogWeb.Controllers;
using NHibernate;
using BlogWeb.Infra;
namespace BlogWeb.Controllers
{
public class GerenciamentoKM
{
private Rota p;
private ISession session;
public GerenciamentoKM(ISession session, Rota p)
{
this.p = p;
this.session = session;
}
public void soma (Rota post)
{
using (ISession session = NHibernateHelper.AbreSession())
{
if (p.Km_Atual <= p.Km_Anterior)
{
ITransaction tx = session.BeginTransaction();
session.Update(post);
tx.Commit();
}
}
}
}
}
Why don’t you put the
if
out of theusing
?– Artur Trapp
A question, you shouldn’t be comparing
if(post.Km_Atual > p.Km_Anterior)
from what I understood the updated data are in the post that is the object being saved correct?– Felipe Assunção
the post serves to pick up information from lamba p, what I tried to do was pull straight from the bank, however it does not work
– Guilherme Padovam
Could you place the code where you instantiate the Managementokm class? And what values are shown in the current p.Km_and previous p.Km_when debugging?
– Cassio Alves