I would like to sum values I get from two columns, these values are added from the data collected in View page based on customers so adding it in a controller from database is not an option as far as I know, I could be wrong Any help would be appreciated.
I can get sum of two columns individually but can't get sum of two columns.
<table class="table">
<tr>
<th>
@Html.DisplayNameFor(model => model.PkgBasePrice)
</th>
<th>
@Html.DisplayNameFor(model => model.Description)
</th>
<th>
@Html.DisplayNameFor(model => model.BasePrice)
</th>
</tr>
@foreach (var item in Model.Where(ModelItem =>
ModelItem.CustomerId.Equals(Session["CustomerId"])))
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.PkgBasePrice)
</td>
<td>
@Html.DisplayFor(modelItem => item.Description)
</td>
<td>
@Html.DisplayFor(modelItem => item.BasePrice)
</td>
</tr>
}
</table>
<h2>
Package Total: [email protected](c =>
c.CustomerId.Equals(Session["CustomerId"])).Sum(b => b.PkgBasePrice)
</h2>
<h2>
Product Total: [email protected](c =>
c.CustomerId.Equals(Session["CustomerId"])).Sum(b => b.BasePrice)
</h2>
I would like to get sum of PkgBasePrice and BasePrice in one amount
Model.Single(ModelItem => ModelItem.CustomerId.Equals(Session["CustomerId"])).Sum(x => x.PkgBasePrice) + Model.Single(ModelItem => ModelItem.CustomerId.Equals(Session["CustomerId"])).Sum(x => x.BasePrice)?@(Model..... + Model....)see my answer