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); }
public async Task <bool> Handle(CommandWithResourceId <int, UpdateProposalCountriesCommand, bool> request, CancellationToken cancellationToken) { var proposal = await _context.Proposals.FindByIdAsync(request.ResourceId, cancellationToken); proposal.UpdateCountries(request.InnerCommand.Countries); await _context.SaveChangesAsync(cancellationToken); return(true); }
public async Task <bool> Handle(UpdateProposalCommand request, CancellationToken cancellationToken) { var proposal = await _context.Proposals.FindByIdAsync(request.ProposalId, cancellationToken); proposal.SetGeneralProperties(request.Name, request.ClientName, request.Comments); await _context.SaveChangesAsync(cancellationToken); return(true); }
public async Task <int> Handle(CreateProposalCommand request, CancellationToken cancellationToken) { var proposal = new Proposal(request.Countries); proposal.SetGeneralProperties(request.Name, request.ClientName, request.Comments); _context.Proposals.Add(proposal); await _context.SaveChangesAsync(cancellationToken); return(proposal.Id); }
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); }