How to pass complex ViewModel to Service Layer in ASP.NET MVC?

前端 未结 1 1449
广开言路
广开言路 2020-12-28 11:36

Say I have RegisterModel for user registration and some UserService that implementing IUserService

public interface IUserService
{
   User CreateUser(User ne         


        
相关标签:
1条回答
  • 2020-12-28 12:24

    You never pass a view model to a service. A service doesn't even know about the existence of a view model that you might have defined in your GUI (ASP.NET MVC) tier. A service works with domain models. Personally I use AutoMapper to map between view models and models and vice versa, so this logic goes into the mapping layer.

    0 讨论(0)
提交回复
热议问题