Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 7 years ago.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Improve this question
What library i need for IEmailSender in asp.net mvc 5 ?
This is how code looks like:
public class PasswordResetHelper
{
private IEmailSender emailSender;
public PasswordResetHelper(IEmailSender emailSenderParam)
{
emailSender = emailSenderParam;
}
public void ResetPassword()
{
// ...call interface methods to configure e-mail details...
emailSender.SendEmail();
}
}
I take that code from a book for mvc 5 but it didn't work.
What i do wrong ?
P.S. Sorry for bad english.
You seem to be looking for a piece of code that will send emails for you. This isn't in that book.
The code you show is in a chapter that's titled "Building Loosely Coupled Components":
[...] one of [the] most important features of the MVC pattern is that it enables separation of concerns. [...] A simple example will help put things in context. If we were writing a component called MyEmailSender to send e-mail messages [...]
Emphasis mine.
They're trying to teach you the concept of building good, maintainable, testable software through separation of concerns and dependency injection.
If you're just looking for copy-pasteable code to implement an email sending class, you've bought the wrong book.
If all you're looking for is code to send an email, see How to send email in ASP.NET C#.
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 5 years ago.
Improve this question
Can anyone please give any doc link or video which I can refer to get a good understanding of Dependency Injection(preferably using Autofac or StructureMap).
Any help would be highly appreciated
First try and understand the principle of DI without a DI container like AutoFac or StructureMap, sometimes called Pure DI, then you might find what a DI container's purpose is, which might help in gaining an understanding of the whole process
This question answers what DI is quite well.
DI containers are just libraries for automating the process of creating your object graphs.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 4 years ago.
Improve this question
So I was wondering the other day, where to put private methods, that do some dirty work in Web API.
I need to extract certain things from JSON, methods will do the job and return some result.
So where do I keep those methods?
do I need to write a separate library (dll)?
or just do this stuff in the controller?
I don’t think it can have a single answer – it depends on…
If you think this private method can be reused from some other controller in future, better to have a separate class, if you think it can be reused from separate modules (not just from controllers), a separate class library project can be the answer.
But if you consider this private method is designed to support for a specific action of a controller, you can write within controller, before taking any decision a few more parameters to be considered like unit testability or slimness of API etc.
You should keep your controller thin as much as possible. You can move logic code to service package, for example JSONService class or JSONLib.
I often use following layout:
controller/
lib/
service/
model/
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 9 years ago.
Improve this question
i am trying to generate pdf using TCPDF and want to attach this PDF to an email,
and send it to various email addresses.
What is the right way to render twig file in Services?
Please take a look at this post, was helpful for me:
http://richsage.co.uk/2011/12/16/rendering-emails-with-twig-in-symfony2/
First, you need to add templating to your service
your_bundle.your_service_name:
class: your_project\your_bundle\Service\your_service
arguments: [#templating]
Then you need to add the templating service to your service constructor
private $templating;
function __construct($templating)
{
$this->templating = $templating;
}
After that you just need to call it in the function that handle the TCPDF rendering
function renderTCPDF()
{
$renderedTemplate = $this->templating->render('your_bundle:template_folder:twig_name', array(your_parameters));
}
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 8 years ago.
Improve this question
I have been searching around but cannot find any site like this. I want to know if there is some dummy server that will respond to test GET requests and return a JSON object? Basically something like:
HTTPUtil.httpGet("http://www.ipsumlorem.com/json");
and have it return filler text JSON objects like:
{
"title" : "Ipsum Lorem",
"content" : "blah blah blah"
}
http://www.jsontest.com/ will be your new best friend I guess...
Try this out for your need: http://echo.jsontest.com/title/ipsum/content/blah
It will return this:
{
"content": "blah",
"title": "ipsum"
}
You can use also www.mocky.io, where you mock your HTTP responses to test your REST API.
It is possible to change also the headers of the response and of course to write precisely the content (including json...)
For following tutorials and giving workshops this could be useful as well:
http://jsonplaceholder.typicode.com
You can use http://apiary.io to create mock REST APIs very quickly.
If you don't care about the Content-Type it is even faster if you put a plain text file in Dropbox.
You could use SoftwareMill's TestServer: https://github.com/softwaremill/softwaremill-common/tree/master/softwaremill-test/softwaremill-test-server
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 4 years ago.
Improve this question
We are building a "configurator" application for conveyors. Basically user comes in and picks a model, then start picking the parts they want. Some components have dependencies on other components. E.g. if I pick Part A, then I am required to select 1 or more Part B's. It is somewhat similar to configuring a PC at Dell.com. The app will also provide suggestions on parts/components.
Based on this info, I am researching if there is an existing pattern(s) that would allow us to make this easy to maintain and design. Any thoughts, ideas? Are there any open source projects that have similar functionality I can borrow ideas/patterns?
I am mostly interested in how to define "rules" between components without hardcoding the rules/dependencies.
Thanks for any help.
Not that it should matter, but we are building this in .NetFramework 3.5/Asp.Net
Without a good reason to do otherwise, I'd keep it simple and each part would have a list of dependent parts.