oop - How to implement concept of .Net RIA Service (Single App Logic) in Asp.Net MVC? -


First, look at the following pictures that explain the concept.

As you are seeing, the app has App Logic (Server Rules) which is server side (database + repository + external services) and client side (ASPN Web page + Silverlight + WCF) can be implemented.

After this, I can create some data squares that contain some validation rules.

  Namespace [solution]. Models {Public Interface IUser {Guid ID {get; Set; } [Required] [string length (15)] [regular expression ("^ [a-ja-z] [a-ga-z_] + $")] string login name {received; Set; } [Required] [string lang (255)] string hashed password {received; Set; } Create date time {receive; Set; } [String lang (255)] string description {get; Set; } [Required] Role role (get; set;}}}  

After that, when users post it to the controllers, then I have some custom model bunders Therefore, I can make sure that every model is valid before I save it.

  Public action SaveData () {if (ModelState.IsValid) {// Logic to save data} to display other {// logic error messages}}  

However, some visible pages do not require all fields in the data type, in which some fields are required in the data type. I can not separate this data type into several interfaces, Depending on which data field page is required to view, because some data fields are duplicates, apart from this app logic will also be different.

For example

  1. Logon view If only include Logonnam and uses 2 fields including Hasej password.
  2. Bdlenpasward view the use of only 2 fields, including ID and Hasej Pashward.
  3. Uses 4 fields including user profile view ID, logonname, hashase password and description.

Do you have an idea to solve this problem? I feel like the concept of AOP.

By the way, I can sort by adding a list field that contains unused fields. But this idea is quite bad when I use it with a large data type that has more than 100 fields.

  Namespace [solution]. Models {public interface IUser / / some defined data types * / / All fields included in this list will not be valid by prescribed rules. & Lt; String & gt; Unused field {set; Set; }}}  

Thanks,

< P> The basic issue here has been considered as one of the following:

  1. Relevant validation rules are being expressed as irregularities
  2. Organizations with disgruntled atprises prematurely Created / Valid

I can suggest that you do not have to try to validate and validate the types of model Binders Not do which are not obtainable all invariant information from HTTP requests. In the case of logon, only your information is the user's name and password, so the logon should not expect the user type, but the user name and password may have been explained in the credentials type.


Comments

Popular posts from this blog

asp.net - Javascript/DOM Why is does my form not support submit()? -

sockets - Delphi: TTcpServer, connection reset when reading -

javascript - Classic ASP "ExecuteGlobal" statement acting differently on two servers -