예제 #1
0
        public async Task <ProjectCurrencyChangedModel> Handle(ChangeProjectCurrencyRequest request, CancellationToken cancellationToken)
        {
            return(await fDbTransactionService.InTransactionAsync(async() =>
            {
                var oldCurrency = await fProjectRepository.ChangeCurrencyAsync(request.Model.ProjectId, request.Model.NewCurrencyType, cancellationToken);
                long updatedCount = 0;
                if (request.Model.Rate != 1)
                {
                    updatedCount = await fExpenseRepository.ChangeCurrencyAsync(request.Model.ProjectId, request.Model.Rate, cancellationToken);
                }

                return new ProjectCurrencyChangedModel
                {
                    OldCurrencyType = oldCurrency,
                    NewCurrencyType = request.Model.NewCurrencyType,
                    ExpensesChangedCount = updatedCount
                };
            }, cancellationToken));
        }