c# - asp net mvc validation and ViewModel -


i have 4 layer solution medium size project:

  1. model (ef poco entities)
  2. data (ef objectcontext)
  3. services
  4. asp net mvc question

    a)should have validation attributes- dataanotation in models or mvc project?

    b)where should set viewmodel-s if in mvc fill viewmodels data, in controller? else if on other project should create repository vewmodel?

    c) should viewmodel have validation>?

a, c) if have view models different dtos, might prefer use dataannotations in both types. way, can validate before try persist , again persist in case dtos used outside scope of mvc app.

b) tuck view models models folder of mvc app , dtos data project separate mvc app. use automapper lot copy values between view models , dtos.


Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -