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");
        }
Esempio n. 2
0
        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");
        }
Esempio n. 3
0
        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");
        }