Exemple #1
0
        public async Task <IActionResult> AcceptInvitationAsync(UserInvitationDto userInvitationDto)
        {
            var userId = await _userCommandService.AcceptInvitationAsync(userInvitationDto);

            var user = await _userQueryService.GetUserByIdAsync(userId);

            await _channelCommandService.AddUserToDefaultChannelsAsync(userId, user.WorkspaceId);

            await _conversationCommandService.StartSelfConversationAsync(userId, user.WorkspaceId);

            return(Ok());
        }
        public async Task <IActionResult> Register([FromBody] WorkspaceDto workspaceDto)
        {
            if (await _userQueryService.IsEmailRegisteredAsync(workspaceDto.Email))
            {
                throw new Exception($"Email \"{workspaceDto.Email}\" is already taken");
            }

            var workspaceId = await _workspaceCommandService.RegisterAsync(workspaceDto.WorkspaceName);

            var userId = await _userCommandService.RegisterAsync(workspaceDto.Email, workspaceDto.Password, workspaceDto.DisplayName, workspaceId);

            await _workspaceCommandService.UpdateOwnerIdAsync(workspaceId, userId);

            await _channelCommandService.AddDefaultChannelsToNewWorkplaceAsync(userId, workspaceId);

            await _channelCommandService.AddUserToDefaultChannelsAsync(userId, workspaceId);

            await _conversationCommandService.StartSelfConversationAsync(userId, workspaceId);

            return(Ok());
        }