コード例 #1
0
        public async Task <bool> Handle(CommandWithResourceId <int, UpdatePayrollScopeCommand, bool> request, CancellationToken cancellationToken)
        {
            var command  = request.InnerCommand;
            var proposal = await _context.Proposals.FindByIdAsync(request.ResourceId, cancellationToken);

            var productScope = new PayrollScopeDto
            {
                CountryScopes = command.CountryScopes
                                .Where(c => c.LevelId > 0)
                                .Select(c => new PayrollCountryScopeDto
                {
                    CountryId         = c.CountryId,
                    LevelId           = c.LevelId,
                    WeeklyPayees      = c.WeeklyPayees,
                    BiWeeklyPayees    = c.BiWeeklyPayees,
                    SemiMonthlyPayees = c.SemiMonthlyPayees,
                    MonthlyPayees     = c.MonthlyPayees,
                    Reporting         = c.Reporting,
                    PayslipStorage    = c.PayslipStorage
                })
            };

            proposal.SetProductScope <PayrollScopeDto, PayrollCountryScopeDto>(ProductType.Payroll, productScope);

            await _context.SaveChangesAsync(cancellationToken);

            return(true);
        }
コード例 #2
0
        public async Task <bool> Handle(CommandWithResourceId <int, UpdateHrScopeCommand, bool> request, CancellationToken cancellationToken)
        {
            var command  = request.InnerCommand;
            var hasLevel = command.LevelId > 0;
            var proposal = await _context.Proposals.FindByIdAsync(request.ResourceId, cancellationToken);

            var productScope = new HrScopeDto
            {
                LevelId       = command.LevelId,
                CountryScopes = command.CountryIds.Select(id => new HrCountryScopeDto
                {
                    CountryId = id
                })
            };

            proposal.SetProductScope <HrScopeDto, HrCountryScopeDto>(ProductType.HR, productScope);

            await _context.SaveChangesAsync(cancellationToken);

            return(true);
        }