Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I use the following convention to help me decide for functionality like you described above:</p> <p><strong>Case:</strong> Check if email address already exists when a user registers</p> <p><strong>1 - Validation Type:</strong> input validation<br> <strong>Description:</strong> is the email in the valid format, length, characters etc.<br> <strong>Done by:</strong> The User object when the property is set, else it will throw an exception </p> <p><strong>2 - Validation Type:</strong> business rule validation<br> <strong>Description:</strong> does a user with the same email already exist or any such business rule?<br> <strong>Done by:</strong> The UserRepository as it will be able to query across all the users to find this information before the Commit is called </p> <p>Based on this, my code for the user would look like: </p> <pre><code>// Method - can be called by the Controller layer to register a user // Can be a private method of the controller itself or can be abstracted by a // IAccountManager implementation with this method void RegisterUser(string emailId){ var user = new User(); user.Email = emailId; if(!user.IsValid){ // Some input data is not correct // Handle the case &amp; exit this method } var repository = serviceLocator.GetInstance&lt;IUserRepository&gt;(); repository.Save(user); if(!repository.IsValid){ // Some business rule error // Handle the case &amp; exit this method } else{ repository.Commit(); } } </code></pre> <p>So, while I understand you are having trouble looking at all the layers, I would categorize them as:</p> <p>Web Project - is the View part of your application &amp; will have only databing logic to output a view<br> Models - a POCO's with logic to validate themselves<br> Repository - calls the persistance layer if the object is valid &amp; all the business rules are valid<br> Persistance layer - persists the data to the store<br> IoC/DI - will resolve instances &amp; give you the correct instance to work with </p> <p>HTH</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.
 

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