1
I have a Repair table in it I have Valuemade, Value and Total Value all of the decimal type. The Value field = Valuemaod + Value Library. However this returning 0. I am showing this in the Detail View when I click I will see the repair summary with its full price.
My Repair and Inspection/details
public ActionResult Detalhes(int id)
{
    decimal total = 0m;
    ConsertoVM model;
    using (Db db = new Db())
    {
        Conserto cons = db.Conserto.Find(id);
        decimal peca = cons.Pecas.ValorUnitatio;
        total += (cons.ValorMaoObra + peca);
        model = new ConsertoVM(cons);
    }
    return View(model);
}
I didn’t see where you’re setting the value in the field
ValorTotalthat you mentioned in the question, only in the variabletotal– Ricardo Pontual
You don’t have to do this so you can do it right in your View if it’s just to add a piece of data. what is inside Reparaovm, has access to the values of Cons?
– novic
i created a total variable that receives the sum of Value
– Cezar Mdlosci
- Ricardo Pontual - that was I only created the total variable just to see if it was getting the right value, however I was still not assigning the value to variable valueTotal, so it was showing 0, beginner né haha vlw
– Cezar Mdlosci
Put this operation in Reparaovm! and search for the method in your View! It’s that simple, what you’re doing won’t work
– novic
I’m voting to close this post because it was a small mistake that the AP has already solved with the help in the comments.
– Jéf Bueno