I am developing a MVC 5 internet application and have a question in regards to having a custom object in the ApplicationUser object.
I have a public virtual Account account object in the ApplicationUser object that holds many maximum count variables for objects in my MVC 5 application. This is set for each user when a user registers an account.
Before I create a model object, I check to see if the user has not exceeded their maximum count for the model object. This is done in a service class for the object.
Here is an example of the code used for a file object:
var userManager = new UserManager<ApplicationUser>(new UserStore<ApplicationUser>(new ApplicationDbContext()));
ApplicationUser user = userManager.FindByNameAsync(userName).Result;
int maxFiles = user.account.maxFiles;
I am using many service classes for many objects with similar code to retrieve the ApplicationUser object.
My question is this: Rather than retrieving the ApplicationUser object each time, for each service class, is it possible to store this object when the user logs on, and then refer to this object before a model object is created? If so, where can I store this object for the above purpose?
Also, how much memory/bandwidth is used when retrieving the ApplicationUser object? Is there minimal memory/bandwidth used such that I do not need to worry about memory/bandwidth when retrieving the ApplicationUser object each time before I create a model object?
Thanks in advance.