2
I am creating a web application MVC 5 for studies and I have a question: it is possible to perform a mathematical operation in view?
I wanted to multiply line 16. What would be the solution?
@foreach (var item in Model) {
<tr>
<td>
@Html.DisplayFor(modelItem => item.users.first_name_user) @Html.DisplayFor(modelItem => item.users.last_name_user)
</td>
<td>
@Html.DisplayFor(modelItem => item.product.name_product)
</td>
<td>
@Html.DisplayFor(modelItem => item.quantity)
</td>
<td>
R$ @Html.DisplayFor(modelItem => item.product.price)
</td>
<td>
@Html.DisplayFor(modelItem => item.quantity) * @Html.DisplayFor(modelItem => item.product.price) ******Preciso Realizar essa multiplicação****
</td>
<td>
@Html.ActionLink("Editar", "Edit", new { id = item.id_order }) |
@Html.ActionLink("Detalhes", "Details", new { id = item.id_order }) |
@Html.ActionLink("Excluir", "Delete", new { id = item.id_order })
</td>
</tr>
}
I tried to use the code that way:
R$ @Html.DisplayFor(modelItem => item.quantity * item.product.price)
Made that mistake:
Why don’t you ride the model already with this calculated field. It is until the most certain to do.
– Maniero
Um, I hadn’t thought about the model. It came automatically mounted from a sql server database. I changing the model, it causes some impact on my database?
– Eric Clero
No, it’s all right.
– Maniero
You are using ORM ???
– novic
As a matter of fact, a week ago I started working on Asp. So I don’t know about ORM, but I will research about.
– Eric Clero