Example #1
0
 private DomainModel()
 {
     _carCatalog      = new CarCatalog();
     _customerCatalog = new CustomerCatalog();
     _employeeCatalog = new EmployeeCatalog();
     _saleCatalog     = new SaleCatalog();
 }
        public void SetUp()
        {
            _personOne = new Person(
                "Ivanov Ivan Ivanovich",
                "01.01.1990",
                "Nezavertailovka",
                "AA2281337"
                );

            _personTwo = new Person(
                "Alekseyev Artyom Ivanovich",
                "21.01.1991",
                "Moscow",
                "AA1488146"
                );

            _personThree = new Person(
                "Nesterov Dmitry Sergeevich",
                "12.01.1990",
                "Sankt-Petersburg",
                "AA4515515"
                );

            _employeeCatalog = new EmployeeCatalog(new Dictionary <Person, string>
            {
                { _personOne, "Tiraet" },
                { _personTwo, "JetBrains" },
                { _personThree, "SPBSU" }
            });
        }
 public LogInViewModel()
 {
     EmployeeCatalog  = new EmployeeCatalog();
     Employees        = new Employee();
     AddItemCommand   = new RelayCommand(DoLogInUser);
     _frameNavigation = new FrameNavigation();
 }
        public CreateEmployeeViewModel()
        {
            this._employeeFactory = new EmployeeFactory();

            this._employeeCatalog = EmployeeCatalog.Instance;

            this.AddCommand = new RelayCommand <Employee>(
                this._employeeFactory.Create,
                employee =>
                this._employeeFactory.CanCreate(
                    this._employeeFactory
                    .NewEmployee));
        }
 public EmployeeViewModel()
 {
     this._projectCatalog      = ProjectCatalog.Instance;
     this._employeeCatalog     = EmployeeCatalog.Instance;
     this._projectsForEmployee = ProjectForEmployeesCatalog.Instance;
     this._canEdit             = false;
     this.DeleteCommand        = new RelayCommand <Employee>(
         () =>
     {
         this._employeeCatalog.Remove(
             this
             ._selectedEmployee);
         this._selectedEmployee = null;
         this.OnPropertyChanged(nameof(this.EmployeeList));
     },
         employee =>
         this._employeeCatalog.EmployeeList.Contains(
             this
             .SelectedEmployee));
     this.UpdateCommand = new RelayCommand <Employee>(
         () =>
     {
         int id = this._selectedEmployee.EmployeeId;
         this._employeeCatalog.Update(
             this
             ._selectedEmployee);
         this.OnPropertyChanged(nameof(this.EmployeeList));
         this.SelectedEmployee =
             this.EmployeeList.Find(
                 employee =>
                 employee.EmployeeId
                 == id);
     },
         employee => this.Edit);
     this.RefreshCommand = new RelayCommand <bool>(
         () =>
     {
         this._projectCatalog.Load();
         this._employeeCatalog.Load();
         this._selectedEmployee = null;
         this.OnPropertyChanged(nameof(this.EmployeeList));
     });
 }
Example #6
0
        static void Main(string[] args)
        {
            Position.Position p1 = new Position.Position(Position.position.manager, 100000);
            Position.Position p2 = new Position.Position(Position.position.economist, 150000);
            Position.Position p3 = new Position.Position(Position.position.accountant, 150000);
            Position.Position p4 = new Position.Position(Position.position.system_administrator, 180000);
            Position.Position p5 = new Position.Position(Position.position.boss, 300000);

            Position.PositionCatalog posCatalog = new PositionCatalog();
            posCatalog.CreatePosition(p1);
            posCatalog.CreatePosition(p2);
            posCatalog.CreatePosition(p3);
            posCatalog.CreatePosition(p4);
            posCatalog.CreatePosition(p5);

            Employee empl1 = new Employee(p1);

            empl1.Name = "John Doe";
            Employee empl2 = new Employee(p2);

            empl2.Name = "John Man";
            Employee empl3 = new Employee(p3);

            empl3.Name = "John Glu";
            Employee empl4 = new Employee(p4);

            empl4.Name = "John Sam";
            Employee empl5 = new Employee(p5);

            empl5.Name = "John Ans";

            EmployeeCatalog emplCat = new EmployeeCatalog();

            emplCat.CreateEmployee(empl1);
            emplCat.CreateEmployee(empl2);
            emplCat.CreateEmployee(empl3);
            emplCat.CreateEmployee(empl4);
            emplCat.CreateEmployee(empl5);

            emplCat.DeleteEmployee("John Man");
        }
        public ProjectViewModel()
        {
            this._projectCatalog             = ProjectCatalog.Instance;
            this._employeeCatalog            = EmployeeCatalog.Instance;
            this._costumerCatalog            = CostumerCatalog.Instance;
            this._projectForEmployeesCatalog = ProjectForEmployeesCatalog.Instance;
            this._addEmployee        = new Employee();
            this._projectForEmployee = new ProjectsForEmployee();

            this.DeleteCommand = new RelayCommand <Project>(
                () =>
            {
                this._projectCatalog.Remove(this.SelectedProject);
                this._selectedProject = null;
                this.OnPropertyChanged(nameof(this.ProjectList));
            },
                project => this.SelectedProject != null);

            this.UpdateCommand = new RelayCommand <Project>(
                () =>
            {
                int id = this._selectedProject.ProjectId;
                this._projectCatalog.Update(this._selectedProject);
                this.OnPropertyChanged(nameof(this.ProjectList));
                this.SelectedProject =
                    this.ProjectList.Find(
                        project =>
                        project.ProjectId
                        == id);
                foreach (ProjectsForEmployee projectsForEmployee in
                         this.EmployeesForProject)
                {
                    this._projectForEmployeesCatalog.Update(
                        projectsForEmployee);
                    this._employeeCatalog.Load();
                }
            },
                project => this.Edit);
            this.AddEmployeeCommand = new RelayCommand <Employee>(
                () =>
            {
                this._projectForEmployee.ProjectId =
                    this._selectedProject.ProjectId;
                this._projectForEmployee.EmployeeId =
                    this._addEmployee.EmployeeId;
                this._projectForEmployee.IsLeader = false;
                this._projectForEmployeesCatalog.Add(
                    this
                    ._projectForEmployee);
                this._employeeCatalog.Load();
                this._addEmployee = new Employee();
                this.OnPropertyChanged(
                    nameof(
                        this.AddEmployeeName
                        ));
                this.OnPropertyChanged(
                    nameof(
                        this
                        .EmployeesForProject
                        ));
                this.AddEmployeeCommand
                .RaiseCanExecuteChanged();
            },
                addEmployee =>
            {
                if (this._addEmployee.Name == null ||
                    this.EmployeesForProject.Exists(
                        employee =>
                        employee
                        .EmployeeId
                        == this
                        ._addEmployee
                        .EmployeeId)
                    )
                {
                    return(false);
                }

                if (this._employeeCatalog.EmployeeList.Exists(
                        employee =>
                        employee
                        .Name
                        == this
                        ._addEmployee
                        .Name) &&
                    this.Edit)
                {
                    return(true);
                }

                return(false);
            });
            this.DeleteEmployeeCommand = new RelayCommand <Employee>(
                () =>
            {
                this._projectForEmployeesCatalog.Remove(
                    this
                    ._selectedEmployee
                    .ProjectsForEmployees
                    .First(
                        employee =>
                        employee
                        .ProjectId
                        == this
                        ._selectedProject
                        .ProjectId));
                this._employeeCatalog.Load();
                this._selectedEmployee = null;
                this.OnPropertyChanged(
                    nameof(
                        this
                        .EmployeesForProject
                        ));
                this.DeleteEmployeeCommand
                .RaiseCanExecuteChanged();
            },
                employee => this._selectedEmployee != null &&
                this._selectedProject != null &&
                this.Edit);
            this._canEdit       = false;
            this.RefreshCommand = new RelayCommand <bool>(
                () =>
            {
                this._projectCatalog.Load();
                this._employeeCatalog.Load();
                this._costumerCatalog.Load();
                this.OnPropertyChanged(nameof(this.ProjectList));
                this.OnPropertyChanged(nameof(this.SelectedProject));
                this.OnPropertyChanged(
                    nameof(this.EmployeesForProject
                           ));
            });
        }
 public CreateEmployeeModel(EmployeeCatalog eCatalog)
 {
     _eCatalog = eCatalog;
 }
 public EditEmployeeModel(EmployeeCatalog eCatalog)
 {
     EditEmployee = new Employee();
     _eCatalog    = eCatalog;
 }
Example #10
0
 public EmployeeModel(EmployeeCatalog eCatalog)
 {
     _eCatalog = eCatalog;
 }
 public RemoveEmployeeModel(EmployeeCatalog eCatalog)
 {
     RemoveEmployee = new Employee();
     _eCatalog      = eCatalog;
 }
Example #12
0
 private DomainModel()
 {
     _employeeCatalog = new EmployeeCatalog();
     //_stationCatalog = new StationCatalog();
 }
Example #13
0
 public EmployeeFactory()
 {
     this.NewEmployee      = new Employee();
     this._employeeCatalog = EmployeeCatalog.Instance;
 }