Beispiel #1
0
        public async Task Handle(DisableTradeCommand notification)
        {
            var entityCurrent = await _tradeRepository.GetByIdAsync(notification.IdTrades);

            if (!IsEntityFound(entityCurrent, notification.MessageType, "Trade.NotFound"))
            {
                return;
            }

            var userEntity = GetUserEntityTrade(notification.UserLoggedIn, entityCurrent.UserGet, entityCurrent.UserLet);

            if (userEntity == null)
            {
                return;
            }
            if (!IsUserCanModifyEntity(notification.UserLoggedIn, userEntity))
            {
                return;
            }

            await _tradeRepository.DisableAsync(entityCurrent.Id);

            if (Commit())
            {
                await _mediator.PublishEvent(new TradeDisabledEvent(_logger, notification.IdTrades));
            }
        }