How to map EditModel to Command Messages?

你。 提交于 2019-12-03 21:21:28

I'd guess it'd be a version of the command pattern that performs the necessary manipulations on the relevant domain objects based on the supplied message. e.g. Something like

public PromoteEmployeeCommand : ICommand {
     private readonly PromotionMessage _message;
     private readonly IEmployeeRepository _repository;

     public PromoteEmployeeCommand(PromotionMessage message,
                                   IEmployeeRepository repository) {
          _message = message;
          _repository = repository;
     }

     public void Execute() {
          /* Get the employee, give them a rise etc... */
     }
}

The mapping from the edit model would resolve to a number of command messages that could be invoked as required (e.g. Give employee a rise, notify their manager, add a note for payroll etc).

The advantage of this approach is that it can isolate your domain model from any presentational concerns exposed by the Edit model.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!