Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I think each ViewModel "knows" what can be done with it, isn't it? So we can make implicit explicit. The ViewModel can explicitly have properties such as CanEdit, CanDelete, etc. </p> <p>The UI should not care <em>why</em> some operations are allowed or not, it simply checks these properties in a way:</p> <pre><code>@if (item.CanEdit) { @Html.ActionLink("Edit Data", "Edit", new {@id = item.Id}) } </code></pre> <p>You can even come up with a helper that takes another <code>boolean</code> as a parameter to decide whether the control should be rendered (or enabled) or not, but it is minor:</p> <pre><code>@Html.SecureActionLink(item.CanEdit, "Edit Data", "Edit", new {@id = item.Id}) </code></pre> <p>The idea is that it is <strong>not</strong> the responsibility of the UI to know how to figure out whether something is permitted due to some business rules or not. But it is definitely UI's responsibility to know how and what to render in one ViewModel is not <code>Editable</code> or another is <code>ReadOnly</code> (different things can have different states).</p> <p>Also, since we are talking about DDD I would advice against modeling CRUD operations. In the end of the day DDD is about Ubiquitous Language, and "Create, Update, Delete" is hardly a language business really speaks.</p> <p>So you will end up with more precise and meaningful properties/operations in your models, such as <code>CanAccept</code> (for order screens) or `CanMakeRefund" (for payments).</p> <p>You resolve/set these properties when you build up your ViewModel and apply security context to it.</p> <p>Hope it helps.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload