I am working on an application where I can have Teacher, Student etc role. Some of the functionality is similar so I also have a base class User. User contains AddRole method and other stuff.
Now, I want that when the Teacher object is created the "Teacher" role is automatically assigned to the object. I am doing this inside the constructor but I think it is ugly. Here is the code:
public class Teacher : User
{
public Teacher()
{
AddRole(new Role() { RoleName = "Teacher"});
}
}
There is no Teacher table in the database. Everything is User based. Teacher is just a Role and have different functionality then a Student.
How would I go about this?