Пример #1
0
        public async Task HandleAsync(CreatePortfolio command)
        {
            try
            {
                var portfolioCreated = await portfolioService.CreatePortfolioAsync(command);

                if (portfolioCreated == null)
                {
                    await busClient.PublishAsync(new CreatePortfolioRejected(command.UserId, command.Name, "Problem resolving the portfolio.", "400"));
                }
                else
                {
                    await busClient.PublishAsync(new PortfolioCreated(portfolioCreated.UserId, portfolioCreated.PortfolioId,
                                                                      portfolioCreated.LiquidationValue, portfolioCreated.ProfitAndLoss, portfolioCreated.Name, portfolioCreated.CreatedAt));
                }
            }
            catch (CustomException ex)
            {
                await busClient.PublishAsync(new CreatePortfolioRejected(command.UserId, command.Name, "Problem saving portfolio.", ex.Code));
            }
        }