/// <summary> /// Constructor /// </summary> /// <param name="employeesTabViewModel">Employess tab view model</param> /// <param name="employeeEditWindow">Employee edit window</param> /// <param name="employee">Employee</param> public EmployeeEditWindowViewModel(EmployeesTabViewModel employeesTabViewModel, EmployeeEditWindow employeeEditWindow, Employee employee) : base(employeesTabViewModel, employeeEditWindow, employee) { if (Update) { EditUser = false; if (employee is Administrator) { Employee = new Administrator { OwnerID = employee.OwnerID, Name = employee.Name, Surname = employee.Surname, PESEL = employee.PESEL, Telephone = employee.Telephone, City = employee.City, Street = employee.Street, HouseNumber = employee.HouseNumber, LocalNumber = employee.LocalNumber, BankAccountNumber = employee.BankAccountNumber, Salary = employee.Salary, Username = employee.Username }; EmployeeRole = EmployeeRole.Administrator; _orginalRole = EmployeeRole.Administrator; } else if (employee is Menager) { Employee = new Menager { OwnerID = employee.OwnerID, Name = employee.Name, Surname = employee.Surname, PESEL = employee.PESEL, Telephone = employee.Telephone, City = employee.City, Street = employee.Street, HouseNumber = employee.HouseNumber, LocalNumber = employee.LocalNumber, BankAccountNumber = employee.BankAccountNumber, Salary = employee.Salary, Username = employee.Username }; EmployeeRole = EmployeeRole.Menager; _orginalRole = EmployeeRole.Menager; } else if (employee is Dispatcher) { Employee = new Dispatcher { OwnerID = employee.OwnerID, Name = employee.Name, Surname = employee.Surname, PESEL = employee.PESEL, Telephone = employee.Telephone, City = employee.City, Street = employee.Street, HouseNumber = employee.HouseNumber, LocalNumber = employee.LocalNumber, BankAccountNumber = employee.BankAccountNumber, Salary = employee.Salary, Username = employee.Username }; EmployeeRole = EmployeeRole.Dispatcher; _orginalRole = EmployeeRole.Dispatcher; } else { Employee = new Employee { OwnerID = employee.OwnerID, Name = employee.Name, Surname = employee.Surname, PESEL = employee.PESEL, Telephone = employee.Telephone, City = employee.City, Street = employee.Street, HouseNumber = employee.HouseNumber, LocalNumber = employee.LocalNumber, BankAccountNumber = employee.BankAccountNumber, Salary = employee.Salary, Username = employee.Username }; EmployeeRole = EmployeeRole.Other; _orginalRole = EmployeeRole.Other; } } else { EditUser = true; Employee = new Employee(); } using (var con = new BaudiDbContext()) { _currentUserNames = Update ? con.Employees.Where(e => e.OwnerID != employee.OwnerID).Select(e => e.Username).ToList() : con.Employees.Select(e => e.Username).ToList(); } }
private Employee EmployeeFactory() { Employee employee; if (EmployeeRole == EmployeeRole.Administrator) { employee = new Administrator(); } else if (EmployeeRole == EmployeeRole.Menager) { employee = new Menager(); } else if (EmployeeRole == EmployeeRole.Dispatcher) { employee = new Dispatcher(); } else { employee = new Employee(); } return employee; }