So, I'm using the code below to show a couple of elements on the page on initial load.
<script type="text/javascript">
$(function(){
@if (ViewBag.PageFunction == "Edit" && Model.ProductType.ProductTypeName == "Book")
{
@:$('#product-isbn').show();
}
@if (ViewBag.PageFunction == "Edit" && Model.HasBulkDiscount == true)
{
@:$('#product-bulk-discount').show();
}
});
</script>
We've recently moved to MVC and my manager and a co-worker are telling me that the top control structure is business logic but the bottom one is not business logic, and that I should not have business logic in my view.
I disagree and feel like this is perfectly valid code to have in my view. Am I right or am I wrong?
My manager also told me I shouldn't be using @Html.LabelFor() in my view either because it is not reusable. Here's an example of how I'm using it.
<div class="form-group">
<p>@Html.LabelFor(p => p.ProductName, new { @class = "col-sm-12" })</p>
<div class="col-sm-12">
@Html.TextBoxFor(p => p.ProductName, new { @class = "form-control" })
</div>
</div>
Not sure if I understand that reasoning either.
Aucun commentaire:
Enregistrer un commentaire