示例#1
0
        public EmployeeContract Add(EmployeeContractViewModel vm, string companyCode)
        {
            var entity = _mapper.Map <EmployeeContract>(vm);

            entity.ContractNumber = $"HDE{companyCode}{_employeeContractRepository.FindAll().ToList().Count + 1}";
            _employeeContractRepository.Add(entity);
            return(entity);
        }
示例#2
0
        public async Task <ActionResult> EmployeesToUnassign(int employeeID, int contractID)
        {
            EmployeeContract employeeContract = await employeeRepository.GetEmployeeContract(employeeID, contractID);

            if (employeeContract == null)
            {
                return(HttpNotFound());
            }
            var model = new EmployeeContractViewModel(employeeContract);

            return(View(model));
        }
 public IActionResult Update([FromBody] EmployeeContractViewModel Vm)
 {
     try
     {
         var companyExpired = _companyDetailService.CheckCompanyExpried(Vm.CompanyId);
         if (companyExpired != null)
         {
             return(new OkObjectResult(companyExpired));
         }
         _employeeContractService.Update(Vm);
         SaveChanges();
         return(new OkObjectResult(new GenericResult(null, true, ErrorMsg.SUCCEED, ErrorCode.SUCCEED_CODE)));
     }
     catch (Exception ex)
     {
         return(new OkObjectResult(new GenericResult(null, false, ErrorMsg.HAS_ERROR, ErrorCode.ERROR_CODE)));
     }
 }
示例#4
0
        public void Update(EmployeeContractViewModel vm)
        {
            var entity = _mapper.Map <EmployeeContract>(vm);

            _employeeContractRepository.Update(entity);
        }
        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
                            });
                        }
                    }
                }
            }
        }