Hello
After the comment below I update the Question to clear it out.
What I want to achieve is add a Role to my Employee Object after I Create it
For Example User Creating an Employee by Fulling the form in web application then he decide This Employee(Object) Will now become an Supervisor or Warehouse Op.
in moment when he decide to create a new instance of This object it will inherit all properties and add new in this case the properties i add to the Supervisor Warehouse class
I expect in result get a View what will allow me to pick an Employee Object from the List and a Position (Role) he will be promoted and add it to Database by that it will create an relation between Employee table and for example Position table:
Mr.X
ID
First name
Last Name
...
PositionID
Position Name
and then additional properties what will be added by the property of the new Object what will be created and called Supervisor
at last that how I See that but I can be mistaken and I'm looking for some help
to understand it better also I'm looking for some examples to make sure I can memories them till now most of the tutorials I saw was on Cars Aliens and it's not helping me. That's why I create my own project with a real life concept from my work and I'm trying to learn on hard way by doing mistakes and asking Questions.
I hope i find someone who have some spear time and will explain me that on my own example what i understand
I am confused with that all information and the way to achieve my goal can be easier then I think only involve more Loops
Employee will be just a new object with the properties I add right ?
That's mean by using Supervisor : Employee Supervisor will be also a totally new Object what have all properties of Employee + the properties I include in Supervisor Class Right ??
If I follow That Logic its no point to create Supervisor Object because it will be total new Object Right ?
Then to make it Right I need to create class called Position what will have an ID
and property List<employee> and List<rols>
then create a Supervisor Object and Warehouse op object with all properties and name of Object
as that two object then I can send the ID in int or name in string to List<rols> to make sure my User can choose what Role/Position this employee will have
after that in View I can use razor syntax to state if he choose Supervisor show properties of this object or show properties of Warehouse Op of cores as a text box to full in and add to database then the same in Controller to make sure it will update right tables ????
public class Employee
{
[Key]
public virtual int EmployeeID { get; set; }
[ForeignKey("TitleID")]
public virtual Title Title { get; set; }
[Display(Name = "Title")]
public virtual int TitleID { get; set; }
...
public byte[] Photo { get; set; }
[HiddenInput(DisplayValue = true)]
public string ImageMimeType { get; set; }
}
public class Position
{
[Key]
public virtual int PositionID { get; set; }
public virtual string PositionName { get; set; }
[ForeignKey("EmployeeID")]
public virtual int EmployeeID { get; set; }
public virtual Employee Employee { get; set; }
}
public class WarehouseOp : Employee
{
public virtual string PositionName { get; set { value = "Warehouse Op"; } }
public virtual string RfNr { get; set; }
public virtual string GrfNr { get; set; }
}
public class Supervisor : Employee
{
public virtual string PositionName { get; set{ value = "Supervisor"; } }
public virtual string TeamName { get; set; }
}
}
Best Regards