private async Task OnSuccess(TimeState timeState) { var message = new VoiceCommandUserMessage { DisplayMessage = timeState.IsEntered() ? CTime2VoiceCommandServiceResources.Get("SuccessfullyCheckedIn") : CTime2VoiceCommandServiceResources.Get("SuccessfullyCheckedOut"), SpokenMessage = timeState.IsEntered() ? CTime2VoiceCommandServiceResources.Get("SuccessfullyCheckedIn") : CTime2VoiceCommandServiceResources.Get("SuccessfullyCheckedOut"), }; var response = VoiceCommandResponse.CreateResponse(message); await this._connection.ReportSuccessAsync(response); }
public async Task Stamp(ICTimeStampHelperCallback callback, TimeState timeState) { await this._applicationStateService.RestoreStateAsync(); if (this._applicationStateService.GetCurrentUser() == null) { Logger.Info("User is not logged in."); await callback.OnNotLoggedIn(); return; } bool checkedIn = await this._cTimeService.IsCurrentlyCheckedIn(this._applicationStateService.GetCurrentUser().Id); if (checkedIn && timeState.IsEntered()) { if (callback.SupportsQuestions()) { Logger.Info("User wants to check-in. But he is already. Asking him if he wants to check-out instead."); var checkOutResult = await callback.OnAlreadyCheckedInWannaCheckOut(); if (checkOutResult == false) { Logger.Info("User does not want to check-out. Doing nothing."); await callback.OnDidNothing(); return; } timeState = TimeState.Left; } else { Logger.Info("User wants to check-in. But he is already. Doing nothing."); await callback.OnAlreadyCheckedIn(); return; } } if (checkedIn == false && timeState.IsLeft()) { if (callback.SupportsQuestions()) { Logger.Info("User wants to check-out. But he is already. Asking him if he wants to check-in instead."); var checkInResult = await callback.OnAlreadyCheckedOutWannaCheckIn(); if (checkInResult == false) { Logger.Info("User does not want to check-in. Doing nothing."); await callback.OnDidNothing(); return; } timeState = TimeState.Entered; } else { Logger.Info("User wants to check-out. But he is already. Doing nothing."); await callback.OnAlreadyCheckedOut(); return; } } Logger.Info("Saving the timer."); await this._cTimeService.SaveTimer( this._applicationStateService.GetCurrentUser(), timeState); Logger.Info("Finished voice command."); await callback.OnSuccess(timeState); }