Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert Users ControllersExtensions into Services #11002

Closed
wants to merge 5 commits into from

Conversation

hishamco
Copy link
Member

No description provided.

@hishamco hishamco changed the title Make user ControllersExtensions public Make Users ControllersExtensions public Jan 10, 2022
@rjpowers10
Copy link
Contributor

I know these have been extension methods since the beginning but something I've always wondered is, would these be better as services? It always stuck me as a bit odd that they are extension methods instead of service methods, but maybe there was a good reason for that. Since you are making them public, maybe this would be a good opportunity to refactor them into services. Since they were internal before I don't think moving them to services would be a breaking change.

@deanmarcussen
Copy link
Member

I would prefer them as services, same with the extension method being added on the tenants pr.

Just seems to make more sense to me, as I've fought around them in the past.

changing how email is sent is a common requirement, and it's quite hard to do with those extensions

and you're quite right @rjpowers10 non breaking.

@hishamco
Copy link
Member Author

I will try to convert them as service, but naming is hard ;) while they provide different functionality to the controller according the requirement. Hope to send a PR today

@hishamco hishamco force-pushed the hishamco/controller-extensions branch from eeed746 to dc256ec Compare January 13, 2022 07:35
@hishamco hishamco changed the title Make Users ControllersExtensions public Convert Users ControllersExtensions into Services Jan 13, 2022
@hishamco
Copy link
Member Author

@deanmarcussen please let me know if you have any concern about the latest changes, so I can reflected into tenants PR

@hishamco
Copy link
Member Author

Any idea why it fails on Ubuntu?

@jtkech
Copy link
Member

jtkech commented Jan 13, 2022

Just saw that DefaultControllerService is registered as a transient service
So it would need to be stateless or only inject singletons (but it injects scoped services)
So DefaultControllerService would need to be registered as a scoped service.

public static async Task<bool> SendAsync(this ISmtpService smtpService, string email, string subject, IShape model)
{
var body = String.Empty;
var displayHelper = ShellScope.Services.GetService<IDisplayHelper>();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jtkech is this a valid usage or is there a proper way to get such service

@hishamco
Copy link
Member Author

Seems I broke th unit tests ;)

@hishamco
Copy link
Member Author

BTW can we rename the service UserAccountService while it provides a user account functionalities?

@rjpowers10
Copy link
Contributor

Just curious: why no interface for the service? I see that there are virtual methods instead.

@hishamco
Copy link
Member Author

@rjpowers10 we can introduce as an interface but I was thinking this services for a controller only. Anyhow all the feedback are welcome

Copy link
Contributor

This pull request has merge conflicts. Please resolve those before requesting a review.

@hishamco
Copy link
Member Author

Closed in favor of #15360

@hishamco hishamco closed this Feb 19, 2024
@hishamco hishamco deleted the hishamco/controller-extensions branch May 18, 2024 02:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants