title: How can I best handle stopping deletion of a row when records exist?
body: <p>I have a list of book records that shows up on my MVC Razor screen</p>
  
  <pre><code>1  edit   delete   Harry Potter 1
  2  edit   delete   Harry Potter 2
  ..
  3  edit   delete   Harry Potter 25
  </code></pre>
  
  <p>When a user clicks on the [delete] link then control goes to a Delete method on 
  the controller. This then shows a MVC Razor screen which allows the user to confirm 
  the delete (if no stock exists) or cancel the delete (if stock exists). </p>
  
  <p>My question is "where should I check stock" should I check this in the Razor view
  with a statement like the following:</p>
  
  <pre><code>@if (@Model.xxx.Count == 0) {
     show the user a [confirm delete] button 
  }
  
  @if (@Model.xxx.Count != 0) {
     show the user a [cancel button] and a message saying "cannot delete"
  }
  </code></pre>
  
  <p>It seems clunky to do all this in the view but also the controller doesn't quite seem the right place and if in the controller then I am not sure how to code it.</p>