Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>Question - 1</strong></p> <blockquote> <p>Why can't I use the <code>Domain Model</code> directly interact with View or Why can't I Create a <code>View Model</code> and pass all <code>Properties</code> of <code>Domain-Model</code>?</p> </blockquote> <p><strong>Answer</strong></p> <p>Let's say you have 50 fields in your class. I have implemented <em>Data Annotations</em> so <em>Required Fields</em> are also present. ok. I am in Step-1. I submitted the form. My <em>Post Action Method</em> said, Form can't be submitted !!!! Why???</p> <p>It's because there are some <em>Required Fields</em> which are not the Part of Step 1. I have a Question from you. Will you like to keep all <code>Properties</code> as mention in other answer? If you want to add all the properties in one <code>View-Model</code> then why one interact with Domain-Model directly as per the suggestion provided in other answer? So, adding all properties in one View-Model will be worst. right?</p> <p><strong>Question - 2</strong></p> <blockquote> <p>What is the best practive or best suggestion for persisting the data model from page to page as it is filled?</p> </blockquote> <p><strong>Answer</strong></p> <pre><code>1. Use View Models with necessary properties only(that are required for particular Step.). So there can be many View Models on the basis of your Steps. This process will be very useful in long run 2. Use AutoMapper to populate the info required for View Model from Domain Model. </code></pre> <p>Using <code>Strongly Types View Models</code>, once the data is sent to <code>Post Action Method</code> after then As per my knowledge you can use <code>TempData</code> to store the posted data. It is like a <code>DataReader Class</code>, once read, Data will be lost. So that stored data in <code>TempData</code> will become null after read.</p> <pre><code>var Value = TempData["keyName"] //Once read data will be lost </code></pre> <hr> <p><strong>Question - 3</strong></p> <blockquote> <p>The Model has a large enough number of fields that the app will need several pages to collect all of the data.</p> </blockquote> <p><strong>Answer</strong></p> <p>So to persist the data even after the data is read you can <code>Alive</code> it like below</p> <pre><code>var Value = TempData["keyName"]; TempData.Keep(); //Data will not be lost for all Keys TempData.Keep("keyName"); //Data will not be lost for this Key </code></pre> <hr> <p><strong>Question - 4</strong></p> <pre><code>How will you handle the case when you have both Next and Previous Buttons? </code></pre> <p><strong>Answer</strong></p> <p><code>TempData</code> works in new <strong>Tabs/Windows</strong> also, like <code>Session</code> variable does.</p> <p>You could use <code>Session</code> Variable too you are able to keep the data across Controllers/Area as well</p> <p>Hope this post will help you alot.</p>
    singulars
    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. 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.
    3. VO
      singulars
      1. This table or related slice is empty.
    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