确实发送电子邮件所属的应用程序的presentation层或业务层? [英] Does sending an email belong in the presentation layer or business layer of an application?

查看:199
本文介绍了确实发送电子邮件所属的应用程序的presentation层或业务层?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图找出放置code在我的Asp.net MVC应用程序发送电子邮件的最佳区域。现在我的应用程序是安装在2 VS项目分离出从presentation层业务层。我想设置的情况下,当用户重设的密码,业务逻辑更改密码后,服务器将发送一封电子邮件与他们的新生成的密码。

I am trying to figure out the best area to place code to send an email in my Asp.net MVC application. Right now my application is setup in 2 VS projects separating out the business layer from the presentation layer. I am trying to setup a situation that when a user reset's their password, after the business logic changes the password the server will send an email to the user with their newly generated password.

我应该调用code发送电子邮件(包括电子邮件的外观数据)从业务层(在业务层将密码重置),或在presentation层(业务后,层返回一个成功的结果)?

Should I be calling the code to send the email (including data on how the email looks) from the business layer (after the business layer resets the password) or in the presentation layer (after the business layer returns a successful result)?

推荐答案

我与部分同意BobTodd,因为他建议你抽象出来。在那里我(部分)不同意的唯一的部分是它在业务层去。

I partially agree with BobTodd because he's suggesting you abstract it out. The only part where I (partially) disagree is about it going in the business layer.

发送电子邮件依赖于某种物理实现的 - 你不想你的BL绑在相关的一些电子邮件服务提供商外部依赖性

Sending email is dependent on some sort of physical implementation - and you don't want to tie your BL to outside dependencies related to some email provider.

在一个小的项目,你可以将其包含在BL,我猜,让事情变得简单,但我会赞成完全抽象出来的​​,在这种情况下,我把它就像我会处理数据访问。

In a small project you could include it in the BL, I guess, to keep things simple but I'd be in favor of abstracting it out completely, in which case I'd treat it just like i'd treat data Access.

在我对世界的看法有两个地方,你可以把它:

In my view of the world there's two places you could put it:


  • 正如你可能希望从任何地方调用共享服务 - 因为它会被抽象出来你能

  • 为/通过外部服务适配器,这也被抽象出来,但是从BL才能访问 - 这可能反过来又暴露了什么方法(如UI)可以调用(如果你真的想要)

请注意:自我推销警惕! - 摘自我自己的文章之一:的http:/ /morphological.word$p$pss.com/2011/08/29/5-layer-architecture/

Note: Self promotion alert! - taken from one of mine own articles: http://morphological.wordpress.com/2011/08/29/5-layer-architecture/

这篇关于确实发送电子邮件所属的应用程序的presentation层或业务层?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆