If’s condition is not accepting in Asp.net mvc Razor

Asked

Viewed 97 times

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();
                    }
                 }
         }
    }
}
  • 1

    Why don’t you put the if out of the using?

  • 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?

  • 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

  • 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?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.