public IHttpActionResult PostEmployeeSkill(EmployeeSkillsViewModel employeeSkills)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.UpdateEmployeeSkill(employeeSkills.MapTo <EmployeeSkill>());

            return(Ok(employeeSkills));
        }
        public IHttpActionResult PutEmployeeSkill(int id, EmployeeSkillsViewModel employeeSkills)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != employeeSkills.Id)
            {
                return(BadRequest());
            }

            db.UpdateEmployeeSkill(employeeSkills.MapTo <EmployeeSkill>());

            return(StatusCode(HttpStatusCode.NoContent));
        }
Beispiel #3
0
 public static TTarget MapTo <TTarget>(this EmployeeSkillsViewModel source) where TTarget : EmployeeSkill
 {
     return(Mapper.Map <EmployeeSkillsViewModel, TTarget>(source));
 }
        private void LoadChildViewmodels()
        {
            lock (_childVM)
            {
                if (_employee != null && !InDesigner)
                {
                    var isEnabled            = (!IsNew);
                    var isEnabledForFakeUser = (!IsNew);

                    var empVm = new EmployeeDetailViewModel();                   //(EmployeeDetailViewModel) Router.GetNonSharedViewModel(Constants.VIEWMODEL_EMPLOYEEDETAIL);
                    empVm.IsNew               = IsNew;
                    empVm.Employee            = _employee;
                    empVm.PropertyChanged    += EmpVmPropertyChanged;
                    empVm.EmployeeViewModel   = this;
                    empVm.EmployeeWasUpdated += OnEmployeeUpdated;
                    SetViewModelState(empVm, true);
                    _childVM.Add(empVm);

                    if (ViewPermissionHelper.IsViewVisible(Constants.VIEW_EMPLOYEEDATEINTERVALSVIEW))
                    {
                        var empdivm = new EmployeeDateIntervalsViewModel(); //(EmployeeDateIntervalsViewModel)Router.GetNonSharedViewModel(Constants.VIEWMODEL_EMPLOYEEDATEINTERVAL);
                        empdivm.Employee          = _employee;
                        empdivm.EmployeeViewModel = this;
                        SetViewModelState(empdivm, isEnabled);
                        empdivm.EmployeeWasUpdated += OnEmployeeUpdated;
                        _childVM.Add(empdivm);
                    }

                    if (ViewPermissionHelper.IsViewVisible(Constants.VIEW_USERDETAIL))
                    {
                        var userVm = new UserViewModel();                     //(UserViewModel) Router.GetNonSharedViewModel(Constants.VIEWMODEL_USER);
                        userVm.Employee          = _employee;
                        userVm.EmployeeViewModel = this;
                        SetViewModelState(userVm, isEnabled);
                        if (NewOrganizationCreated != null)
                        {
                            userVm.NewOrganizationCreated = NewOrganizationCreated;
                        }
                        userVm.EmployeeWasUpdated += OnEmployeeUpdated;
                        _childVM.Add(userVm);
                    }

                    var planningVm = new PlanningPeriodViewModel();                 //(PlanningPeriodViewModel) Router.GetNonSharedViewModel(Constants.VIEWMODEL_PLANNINGPERIOD);
                    planningVm.Employee          = _employee;
                    planningVm.EmployeeViewModel = this;
                    SetViewModelState(planningVm, isEnabled);
                    planningVm.EmployeeWasUpdated += OnEmployeeUpdated;
                    _childVM.Add(planningVm);

                    var emplVm = new EmploymentViewModel();                 //(EmploymentViewModel) Router.GetNonSharedViewModel(Constants.VIEWMODEL_EMPLOYMENT);
                    emplVm.Employee          = _employee;
                    emplVm.PropertyChanged  += EmplVmPropertyChanged;
                    emplVm.EmployeeViewModel = this;
                    SetViewModelState(emplVm, isEnabled);
                    emplVm.EmployeeWasUpdated += OnEmployeeUpdated;
                    _childVM.Add(emplVm);

                    if (ViewPermissionHelper.IsViewVisible(Constants.VIEW_EMPLOYEEWORKSCHEDULE))
                    {
                        var workScheduleVm = new WorkScheduleViewModel();                     // (WorkScheduleViewModel) Router.GetNonSharedViewModel(Constants.VIEWMODEL_WORKSCHEDULE);
                        workScheduleVm.Employee          = _employee;
                        workScheduleVm.EmployeeViewModel = this;
                        SetViewModelState(workScheduleVm, isEnabled);
                        workScheduleVm.EmployeeWasUpdated += OnEmployeeUpdated;
                        _childVM.Add(workScheduleVm);
                    }

                    if (ViewPermissionHelper.IsViewVisible(Constants.VIEW_EMPLOYEENOTE))
                    {
                        var employeeNoteViewModel = new EmployeeNoteViewModel();                     // (EmployeeNoteViewModel) Router.GetNonSharedViewModel(Constants.VIEWMODEL_EMPLOYEENOTE);
                        employeeNoteViewModel.Employee          = _employee;
                        employeeNoteViewModel.EmployeeViewModel = this;
                        SetViewModelState(employeeNoteViewModel, isEnabled);
                        employeeNoteViewModel.EmployeeWasUpdated += OnEmployeeUpdated;
                        _childVM.Add(employeeNoteViewModel);
                    }

                    if (ViewPermissionHelper.IsViewVisible(Constants.VIEW_EMPLOYEESALARYSUPPLEMENT))
                    {
                        var employeeSalarySupplementsViewModel = new EmployeeSalarySupplementsViewModel();
                        //(EmployeeSalarySupplementsViewModel) Router.GetNonSharedViewModel(Constants.VIEWMODEL_EMPLOYEESALARYSUPPLEMENT);
                        employeeSalarySupplementsViewModel.Employee          = _employee;
                        employeeSalarySupplementsViewModel.EmployeeViewModel = this;
                        if (Employee.FakeUser)
                        {
                            isEnabledForFakeUser = false;
                        }
                        SetViewModelState(employeeSalarySupplementsViewModel, isEnabledForFakeUser);
                        employeeSalarySupplementsViewModel.EmployeeWasUpdated += OnEmployeeUpdated;
                        _childVM.Add(employeeSalarySupplementsViewModel);
                    }

                    if (ViewPermissionHelper.IsViewVisible(Constants.VIEW_EMPLOYEEACCUMULATOR))
                    {
                        var empAccumulatorVm = new EmployeeAccumulatorViewModel();                     //(EmployeeAccumulatorViewModel)Router.GetNonSharedViewModel(Constants.VIEWMODEL_EMPLOYEEACCUMULATOR);
                        empAccumulatorVm.Employee          = _employee;
                        empAccumulatorVm.EmployeeViewModel = this;
                        SetViewModelState(empAccumulatorVm, isEnabled);
                        empAccumulatorVm.EmployeeWasUpdated += OnEmployeeUpdated;
                        _childVM.Add(empAccumulatorVm);
                    }

                    if (ViewPermissionHelper.IsViewVisible(Constants.VIEW_EMPLOYEECONTRACT))
                    {
                        var employeeContractViewModel = new EmployeeContractViewModel();
                        //(EmployeeContractViewModel)Router.GetNonSharedViewModel(Constants.VIEWMODEL_EMPLOYEECONTRACT);
                        employeeContractViewModel.Employee          = _employee;
                        employeeContractViewModel.EmployeeViewModel = this;
                        SetViewModelState(employeeContractViewModel, isEnabled);
                        employeeContractViewModel.EmployeeWasUpdated += OnEmployeeUpdated;
                        _childVM.Add(employeeContractViewModel);
                    }

                    var employeeQualificationsViewModel = new EmployeeQualificationsViewModel();                 // Router.GetNonSharedViewModel(Constants.VIEWMODEL_EMPLOYEEQUALIFICATIONS);
                    employeeQualificationsViewModel.Employee          = _employee;
                    employeeQualificationsViewModel.EmployeeViewModel = this;
                    SetViewModelState(employeeQualificationsViewModel, isEnabled);
                    employeeQualificationsViewModel.EmployeeWasUpdated += OnEmployeeUpdated;
                    _childVM.Add(employeeQualificationsViewModel);

                    var employeeSkillsViewModel = new EmployeeSkillsViewModel();                //(EmployeeSkillsViewModel) Router.GetNonSharedViewModel(Constants.VIEWMODEL_EMPLOYEESKILLS);
                    employeeSkillsViewModel.Employee          = _employee;
                    employeeSkillsViewModel.EmployeeViewModel = this;
                    SetViewModelState(employeeSkillsViewModel, isEnabled);
                    employeeSkillsViewModel.EmployeeWasUpdated += OnEmployeeUpdated;
                    _childVM.Add(employeeSkillsViewModel);

                    var employeeApprovalsViewModel = new EmployeeApprovalsViewModel();                 //(EmployeeApprovalsViewModel)Router.GetNonSharedViewModel(Constants.VIEWMODEL_EMPLOYEEAPPROVALS);
                    employeeApprovalsViewModel.Employee          = _employee;
                    employeeApprovalsViewModel.EmployeeViewModel = this;
                    SetViewModelState(employeeApprovalsViewModel, isEnabled);
                    employeeApprovalsViewModel.EmployeeWasUpdated += OnEmployeeUpdated;
                    _childVM.Add(employeeApprovalsViewModel);

                    var employeePlanningUnitKnowledgeViewModel = new EmployeePlanningUnitKnowledgeViewModel();                 // (EmployeePlanningUnitKnowledgeViewModel)Router.GetNonSharedViewModel(Constants.VIEWMODEL_EMPLOYEEPLANNINGUNITKNOWLEDGE);
                    employeePlanningUnitKnowledgeViewModel.Employee          = _employee;
                    employeePlanningUnitKnowledgeViewModel.EmployeeViewModel = this;
                    SetViewModelState(employeePlanningUnitKnowledgeViewModel, isEnabled);
                    employeePlanningUnitKnowledgeViewModel.EmployeeWasUpdated += OnEmployeeUpdated;
                    _childVM.Add(employeePlanningUnitKnowledgeViewModel);

                    // Monitor childVM:s
                    _editingStates.Clear();
                    foreach (var vm in _childVM)
                    {
                        if (vm is EmployeeDetailViewModel)
                        {
                            vm.MasterViewId = ViewId;
                        }

                        if (!_editingStates.ContainsKey(vm.ViewId))
                        {
                            vm.EditingChanged += vm_EditingChanged;
                            _editingStates.Add(vm.ViewId, new EditingState()
                            {
                                ViewId = vm.ViewId, IsEditing = false
                            });
                        }
                    }
                }
            }
        }