If you are using entity framework would you create separate classes/tables for different Employees and Managers? Or a single table with a flag ?
I am a bit confused as to what would be the better approach. Let's suppose you have Employees and Managers which are basically two different kinds of employees in the end. You could also add HOD(Head of the Department) to this mix.
Manager and HOD have some privileges of course but all the attributes / columns remain almost identical to regular employees. Would you create one table/class or different tables/class?
If I create one table I will have one class or vice versa.
Consider his scenario when a certain person places an expense claim which can be approved by manager if its below $100 else it can be approved only by HOD and so on.
In either case, how does one implement chain of responsibility here?
The following is my understanding of Chain of Responsibility:
abstract class Approver //can be interface
{
protected Approver _successor;
public void SetSuccessor(Approver successor)
{
this._successor=successor;
}
public abstract void ProcessRequest(Purchase purchase)
}
class Manager : Approver
{
public override void ProcessRequest(Purchase purchase)
{
if(purchase.Amount<10000)
{
console.wireline('approved');
}
else if(successor !=null)
{
_successor.ProcessRequest(purchase);
}
}
}
class HOD: Approver
{
public override void ProcessRequest(Purchase purchase)
{
if(purchase.Amount<20000)
{
console.wireline('approved');
}
else if(successor !=null)
{
successor.ProcessRequest(purchase);
}
}
} Approver ronny=new Manager(); Approver bobby=new HOD(); Approver ricky=new President(); ronny.SetSuccessor(bobby); //setting the successors bobby.SetSuccessor(ricky); Purchase p =new Purchase(8880,350,"Assets"); ronny.ProcessRequest(p);
How exactly does this work in entity framework?