I have an application with two entities:
public class Employer {
public string Title {get;set;}
public virtual ICollection<Application> Applications {get;set;}
}
public class Application {
public string Title {get;set;}
}
I want to give users access to specific employers (an employers can have multiple users), so they can submit applications for their employers. This also includes a view of "your" employers. To solve this, I have thought of the following two possibilities:
When an employer is created, a corresponding role is also created. Users can then be added to this role, and I will write some custom logic to check if the user is in the corresponding role. The hard part here is that it seems difficult to connect the role with the employer in any safe manner (without writing my own role provider)
Add a property such as Collection of Users to the Employer class, and check if the current signed in user is in this collection to decide if the user has access.
Are these good solutions, or are there any better ways to solve my problem?