예제 #1
0
        public EditAllocationStructureResultDto EditAllocationStructure(EditAllocationStructureResultDto editAllocationStructureResultDto)
        {
            var employeeMembership = EmployeeMembershipRepository.Load(editAllocationStructureResultDto.EmployeeMembershipId);

            var section            = new B_Section();
            var organizationalCell = new B_OrganizationalCell();
            var organizationalUnit = new B_OrganizationalUnit();
            var employee           = new B_Employee();

            section.SetId(editAllocationStructureResultDto.SectionId);
            organizationalUnit.SetId(editAllocationStructureResultDto.OrganizationalUnitId);
            organizationalCell.SetId(editAllocationStructureResultDto.OrganizationalCellId);
            employee.SetId(editAllocationStructureResultDto.DirectSupervisorId);

            if (editAllocationStructureResultDto.SectionId == 0)
            {
                section = null;
            }
            if (editAllocationStructureResultDto.OrganizationalCellId == 0)
            {
                organizationalCell = null;
            }
            if (editAllocationStructureResultDto.OrganizationalUnitId == 0)
            {
                organizationalUnit = null;
            }
            if (editAllocationStructureResultDto.DirectSupervisorId == 0)
            {
                employee = null;
            }

            employeeMembership.Position           = editAllocationStructureResultDto.Position;
            employeeMembership.Section            = section;
            employeeMembership.OrganizationalCell = organizationalCell;
            employeeMembership.OrganizationalUnit = organizationalUnit;
            employeeMembership.DirectSupervisor   = employee;

            EmployeeMembershipRepository.SaveAndFlush(employeeMembership, editAllocationStructureResultDto.UserId);

            editAllocationStructureResultDto.Success = true;

            return(editAllocationStructureResultDto);
        }
예제 #2
0
        public StructureAndLocationResultDto SaveCoefficients(StructureAndLocationDto structureAndLocationDto)
        {
            B_EmployeeMembershipCoefficients coefficients;
            B_OrganizationalUnit             organizationalUnit = new B_OrganizationalUnit();
            B_OrganizationalCell             organizationalCell = new B_OrganizationalCell();
            B_Silo silo = new B_Silo();

            organizationalUnit.SetId(structureAndLocationDto.OrganizationalUnitId);
            organizationalCell.SetId(structureAndLocationDto.OrganizationalCellId);
            silo.SetId(structureAndLocationDto.SiloId);

            if (structureAndLocationDto.Id == 0)
            {
                var employee = new B_Employee();
                employee.SetId(structureAndLocationDto.EmployeeId);

                coefficients = new B_EmployeeMembershipCoefficients()
                {
                    Employee = employee,
                    FromDate = DateTime.Now,
                };
            }
            else
            {
                coefficients = EmployeeMembershipCoefficientsRepository.Load(structureAndLocationDto.Id);
            }

            coefficients.OrganizationalUnit = organizationalUnit;
            coefficients.OrganizationalCell = organizationalCell;
            coefficients.Silo        = silo;
            coefficients.Coefficient = (float)structureAndLocationDto.Coefficient;

            EmployeeMembershipCoefficientsRepository.SaveAndFlush(coefficients, structureAndLocationDto.UserId);

            var result = new StructureAndLocationResultDto();

            result.Success = true;
            result.Id      = coefficients.Id;

            return(result);
        }