Пример #1
0
        public ControlPanelViewModel(DBContext context, Employee empl)
        {
            dbContext    = context;
            employeeRepo = EmployeeImpl.getInstance(dbContext);
            //adminRepo = new AdminImpl(dbContext);
            projectRepo  = ProjectImpl.getInstance(dbContext);
            reportRepo   = ReportImpl.getInstance(dbContext);
            taskRepo     = TaskImpl.getInstance(dbContext);
            positionRepo = PositionImpl.getInstance(dbContext);
            levelRepo    = LevelImpl.getInstance(dbContext);

            Employees = new ObservableCollection <Employee>(employeeRepo.getAll().Where(user => user.Role == Role.User));
            Admins    = new ObservableCollection <Employee>(employeeRepo.getAll().Where(user => user.Role == Role.Admin));
            foreach (Employee employee in Employees)
            {
                if (employee.PositionId != null)
                {
                    employee.Position = positionRepo.get((int)employee.PositionId);
                }
            }
            Projects  = projectRepo.getAll();
            Tasks     = taskRepo.getAll();
            Levels    = levelRepo.getAll();
            Positions = new ObservableCollection <Position>(new List <Position>(new Position[] { new Developer(), new HumanResources(), new ProjectManager(), new Tester() }));

            EmployeeSelectedIndex = -1;
            AdminSelectedIndex    = -1;
            ProjectSelectedIndex  = -1;
            TaskSelectedIndex     = -1;

            SelectedProject  = new Project();
            SelectedTask     = new Task();
            SelectedEmployee = new Employee();
            SelectedAdmin    = new Employee();
        }
        public ReportingViewModel(DBContext context, Employee empl)
        {
            dbContext    = context;
            employeeRepo = EmployeeImpl.getInstance(dbContext);
            projectRepo  = ProjectImpl.getInstance(dbContext);
            reportRepo   = ReportImpl.getInstance(dbContext);
            taskRepo     = TaskImpl.getInstance(dbContext);
            currentEmpl  = empl;
            selectedDay  = DateTime.Now.Date;
            setWeekCollection(selectedDay);
            setWeekRange(selectedDay);
            SelectedTabIndex = getWeekIndex(selectedDay);
            SelectedReport   = new Report();

            if (empl.ProjectId != null)
            {
                Project pr = projectRepo.get((int)empl.ProjectId);
                Projects.Add(pr);
                Tasks = new ObservableCollection <Task>(taskRepo.getAll().Where(task => task.ProjectId == pr.Id));
            }
        }