public HiddenOptionsDto ShowTrivia(AppName appName, string popUpTitle, DateTime lastPopUpDateTime, int popUpCountToday, int timeOutInMilliSeconds, string optionsName) { HiddenOptionsDto hiddenOptionsDto = null; var clientGateway = new ClientGateway(); var gatewayResponse = clientGateway.GetGatewayResponse(appName, timeOutInMilliSeconds, CommonConstants.TimeOutInMilliSecondsOptionLabel, optionsName); var somethingToShow = false; var triviaDialogDto = new TriviaDialogDto { AppName = appName, OptionsName = optionsName, PopUpTitle = popUpTitle }; if (!string.IsNullOrEmpty(gatewayResponse.ErrorDetails)) { triviaDialogDto.ErrorDetails = gatewayResponse.ErrorDetails; somethingToShow = !string.IsNullOrEmpty(triviaDialogDto.ErrorDetails); } else { switch (appName) { case AppName.Jeopardy: var gatewayResponseJeopardy = (GatewayResponseJeopardy)gatewayResponse; triviaDialogDto.Answer = "A. " + gatewayResponseJeopardy.Answer; triviaDialogDto.Question = "Q. " + gatewayResponseJeopardy.Question; somethingToShow = !string.IsNullOrEmpty(triviaDialogDto.Question); break; case AppName.NumericTrivia: var gatewayResponseNumeric = (GatewayResponseNumericTrivia)gatewayResponse; triviaDialogDto.Fact = gatewayResponseNumeric.NumericFact; somethingToShow = !string.IsNullOrEmpty(triviaDialogDto.Fact); break; case AppName.TrumpQuotes: var gatewayResponseTrump = (GatewayResponseTrumpQuotes)gatewayResponse; triviaDialogDto.HyperLinkUri = gatewayResponseTrump.HyperLinkUri; triviaDialogDto.Quotation = gatewayResponseTrump.TrumpQuote; triviaDialogDto.Attribution = gatewayResponseTrump.QuotationAuthor + spacer + gatewayResponseTrump.QuotationDate + spacer; somethingToShow = !string.IsNullOrEmpty(triviaDialogDto.Quotation); break; } } if (somethingToShow) { DisplayPopUpMessage(triviaDialogDto); hiddenOptionsDto = GetHiddenOptionsDto(lastPopUpDateTime, popUpCountToday); } return(hiddenOptionsDto); }
private HiddenOptionsDto GetHiddenOptionsDto(DateTime lastPopUpDateTime, int popUpCountToday) { var hiddenOptionsDto = new HiddenOptionsDto(); var baseDateTime = DateTime.Now; if (IsANewDay(lastPopUpDateTime, baseDateTime)) { hiddenOptionsDto.PopUpCountToday = 1; } else { hiddenOptionsDto.PopUpCountToday = popUpCountToday + 1; } hiddenOptionsDto.LastPopUpDateTime = baseDateTime; return(hiddenOptionsDto); }