开发者

Getting current office id for user [closed]

开发者 https://www.devze.com 2023-03-26 09:02 出处:网络
Closed. This question needs details or clarity. It is not currently accepting answers. 开发者_开发知识库
Closed. This question needs details or clarity. It is not currently accepting answers.
开发者_开发知识库

Want to improve this question? Add details and clarify the problem by editing this post.

Closed 8 years ago.

Improve this question

In my project once the user logs in they are assigned to an office and based on their office they only get information within that office. I want to get the current id of the user after logging in but i am not sure how to go about that or where to look. Any help or suggestions would be great.

asp.net mvc project.


Regardless of your data store, you could use a similar approach to @Omar's answer in this question I asked some time ago.

The basic idea is to define a parent/base Controller class from which all your relevant controllers inherit. Then, upon initializing that controller:

protected override void Initialize(RequestContext requestContext) { }

You would setup the data based within the office. I can't describe this much further, because you haven't provided a lot of specifics, but within Controller.Initialize you would access this information via AD, your database, etc.

Finally, you could incorporate the retrieved data (via Repositories, etc) into your view models, or pass to the view using ViewData or ViewBag. Though, I recommend the former over the latter in the interest of code cleanliness.

0

精彩评论

暂无评论...
验证码 换一张
取 消