public async Task RevealCurrentStoryAsync(string sessionId, string hostCode) { if (!await _sessionProvider.CheckSessionForHostAsync(sessionId, hostCode, default)) { return; } var session = await _sessionProvider.GetSessionByIdAsync(sessionId, default); var stories = await _storyRepo.GetStoriesBySessionIdAsync(sessionId, default); var currentStory = stories.FirstOrDefault(i => i.StoryId == session.CurrentStoryId); await _storyRepo.RevealStoryAsync(currentStory.StoryId, default); await Clients.Group(sessionId).SendAsync("RevealCurrentStory", sessionId); }
public async Task <IActionResult> CreateSessionAsync(CreateSessionRequest createSessionRequest, CancellationToken cancellationToken) { if (!string.IsNullOrEmpty(createSessionRequest.HostCode) && !string.IsNullOrEmpty(createSessionRequest.SessionId)) { var session = await _sessionProvider.GetSessionByIdAsync(createSessionRequest.SessionId, cancellationToken); var userJoinCheck = await CheckUserCanJoinSessionAsync(session, createSessionRequest.Nickname, createSessionRequest.UserId, createSessionRequest.HostCode, cancellationToken); if (userJoinCheck.GetType() != typeof(OkResult)) { return(userJoinCheck); } } var response = await _sessionProvider.CreateSessionAsync(createSessionRequest, cancellationToken); return(Ok(response)); }