我正在设计基于DDD架构的应用程序,我有以下层 演示文稿(ASP.Net MVC项目) 应用层(服务层,底层到底层) 域层 基础设施层(存储库和工作单元) 基于DDD我应该将DTO从表示层传递到应用层然后映射到域模型发生在应用层,问题是我从Asp.net Identity Frmaework UserManager继承UserManagmentService(应用层)层,当我是调用UserManagmentService.createAsync();方法期望域模型实体所以我不能将DTO传递给UserManagmentService,下面是代码
演示文稿图层(MVC)
public ActionResult Create(FormCollection collection)
{
try
{
var userApplicationService = new UserManagmentService<int>();
var UserDTO=new UserDTO();
UserDTO.name="some Name"
//The below Line Doesnt Work Because it is Expecting The type that is nherited from IdentityUser , which in this case is my domain model , not my DTO
userApplicationService.CreateAsync(UserDTO,password)
return RedirectToAction("Index");
}
catch
{
return View();
}
}
应用层
public class
UserManagmentService<TKey>:UserManager<User,int>,IUserManagmentService<TKey>
{
#region members
#endregion
public UserManagmentService(IUserStore<User,int> store)
: base(store)
{
}
}
}
域名图层
public class User:IdentityUser<int,UserLogin,UserRole,UserClaim>
{
public string firstName { get; set; }
public string lastName { get; set; }
// Extend User Domain Entity Here
}
}
那么我如何在这种情况下使用DTO,我是否应该覆盖UserManagmentService中的所有Usermanager方法?
谢谢