我应该在哪里放置在保存表单之前必须运行的代码?
我有一个虚拟机来控制显示的内容等。在我的例子中 - 它是用户编辑屏幕。
我在用户保存之前有一些代码 - 我输入密码,用盐对其进行加密并将其填充到实体属性中。
那么,这段代码属于哪里呢?现在我正在拦截 OnBeforeSave 并将其放在那里。我应该将其移至模型中吗?
编辑:
有关我的环境/层的更多信息:
- Silverlight
- Views (XAML)
- ViewModel(通过存储库封装数据访问)。公开属性和数据对象以绑定
- 模型 - DevForce 框架响应以实现持久性。我还使用它的验证功能。我可以用部分类等来扩展它。
I have VM which controls what displayed, etc. In my case - it's User editing screen.
I have some code where before user saved - I take entered password, encrypt it with salt and stuff into entity property.
So, where this code belongs? Right now I'm intercepting OnBeforeSave and put it there. Should I move it to the model?
EDIT:
More info on my environment/layers:
- Silverlight
- Views (XAML)
- ViewModel (encapsulates data access via repositories). Exposes properties and data objects to bind
- Model - DevForce framework responsivle for persistance. I also use it's validation functionality. I can extend it with partial classes, etc.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是业务逻辑的完美示例:它不属于模型,它属于采用模型并将其传递到 DAL 或存储库的任何内容。
如果您可以发布有关您的应用程序使用的层或 IoC 风格服务的更多信息,我们可能会更具体。
(MVVM 是关于模型、视图模型和视图的。事实上,这与 MVVM 没有太大关系!)
希望有所帮助。
(编辑:哦,又是你,今天早些时候看到了另一个问题:)我不是在跟踪你..)
That's a perfect example of business logic: it doesn't belong in the model, it belongs in whatever takes the model and passes it to the DAL, or repository, for instance.
If you can post some more info about the layers, or IoC-style services your app uses, we can probably be more specific.
(MVVM is about models, view models and views.. this isn't really much to do with MVVM in fact!)
Hope that helps.
(Edit: ohai it's you again, saw another question earlier today :) I'm not stalking you..)