예제 #1
0
        public async Task <ToggleBlockCharacterResponse> Handle(ToggleBlockCharacterRequest request,
                                                                CancellationToken cancellationToken)
        {
            var blockCharacterResult = await characterManager.ToggleBlockCharacter(request.CharacterId);

            if (blockCharacterResult.IsSucceeded)
            {
                var notification = await notifier.Push(
                    $"Character {blockCharacterResult.CharacterName} has been blocked",
                    blockCharacterResult.AccountId);

                await hubManager.Invoke(SignalrActions.NOTIFICATION_RECEIVED, blockCharacterResult.AccountId,
                                        mapper.Map <NotificationDto>(notification));

                return((ToggleBlockCharacterResponse) new ToggleBlockCharacterResponse
                {
                    IsBlocked = blockCharacterResult.IsBlocked
                }.LogInformation(
                           $"Admin #{httpContextReader.CurrentUserId} blocked character #{request.CharacterId}"));
            }

            throw new CrudException("Toggling block character status failed");
        }