I have an MVC website that uses ASP.NET Identity. This site can be used for multiple customers data, and each customer is independent to another, no data should be shared. Each transaction should happen only on that customers data when that Customer is selected.
However, the Users who log in can see All customers, they just choose at login which customer to transact against.
So upon login, they will pick from a Dropdown their customer, and then see all that customers items, individual information, and unique things that can be done for that customer.
So for example
var allItems = from a in db.Items where a.CustomerId = customerId select a;
This customer Id can be got at login, as its what the User chose from a dropdown. However, how do I persist this choice throughout the entirety of the users log in session? I obviously don't want to save it to the database as its not a permanent choice I want the choice to be gone when they log out, with them to be free to choose another Customer next login.
Another cool thing would be able to override the get method in the DbContext to retreive only items matching whatever customer Id was selected on login
public DbSet<Item> ItemsAll { get; set; }
public IQueryable<Item> Items
{
get
{
return ItemsAll.Where(x => x.Customer == myLoggedInCustomerChoice);
}
}