public async Task Execute(RecalculateBudgetCostCommand command, PerformContext context, IJobCancellationToken cancellationToken) { context.WriteLine($"Recalculating budget cost for {command.BudgetId} started"); var budget = await _budgetRepository.BudgetForIdAsync(command.BudgetId); await budget.CalculateTotalCost(_commissionCalculationService); await _budgetRepository.SaveChangesAsync(cancellationToken.ShutdownToken); context.WriteLine($"Recalculating budget cost for {command.BudgetId} completed"); }
public async Task Execute(AddEmployeeCostToBudgetCommand command, PerformContext context, IJobCancellationToken cancellationToken) { context.WriteLine($"Adding employee cost for budget {command.BudgetId} started"); var budget = await _budgetRepository.BudgetForIdAsync(command.BudgetId); await budget.AddEmployeesCost(command.EmployeeIdentity, command.Participation, _employeeCostService); await _budgetRepository.SaveChangesAsync(cancellationToken.ShutdownToken); context.WriteLine($"Adding employee cost for budget {command.BudgetId} completed"); }
public async Task Execute(Guid budgetId, PerformContext context, IJobCancellationToken cancellationToken) { context.WriteLine($"Updating read model for budget {budgetId} started"); var budget = await _budgetRepository.BudgetForIdAsync(budgetId); var viewModel = _mapper.Map <BudgetViewModel>(budget); UpdateMemoryCache(viewModel); await UpdateNoSqlModel(viewModel, cancellationToken.ShutdownToken); await NotifyClientsBudgetDataChanged(viewModel, cancellationToken.ShutdownToken); context.WriteLine($"Updating read model for budget {budgetId} completed"); }