public IActionResult Index() { // Write the log entry. //_logger.LogInformation("Get Index Method"); IndexViewViewModel indexViewViewModel = new IndexViewViewModel(new TranslationViewModel(), new SelectLanguageTranslationListViewModel()); return(View("Index", indexViewViewModel)); }
public async Task <IActionResult> Index(IndexViewViewModel indexViewViewModel) { if (!ModelState.IsValid) { return(View(new IndexViewViewModel(new TranslationViewModel(), new SelectLanguageTranslationListViewModel()))); } //_logger.LogInformation("_googleReCaptcha.Value.SecretKey"); //_logger.LogInformation(_googleReCaptcha.Value.SecretKey); //_logger.LogInformation("_googleReCaptchaV3.Value.v3_secret");_ //_logger.LogInformation(_googleReCaptchaV3.Value.v3_secret); /* * * var data = await verifyReCaptcha("v2", indexViewViewModel.GoogleReCaptchaResponse); * //_logger.LogInformation("data.IsHttpResponseOk" + data.IsHttpResponseOk.ToString()); * //_logger.LogInformation("indexViewViewModel.GoogleReCaptchaResponse" + indexViewViewModel.GoogleReCaptchaResponse); * //_logger.LogInformation("data.reCaptchaVerifyResponse[\"success\"].ToString().ToLower()" + data.reCaptchaVerifyResponse["success"].ToString().ToLower()); * //_logger.LogInformation("data.reCaptchaVerifyResponse[\"hostname\"].ToString()" + data.reCaptchaVerifyResponse["hostname"].ToString()); * * if (data.IsHttpResponseOk && data.reCaptchaVerifyResponse["success"].ToString().ToLower().Equals("true") && (data.reCaptchaVerifyResponse["hostname"].ToString().Equals("clean-yew-270306.appspot.com"))) * //|| data.reCaptchaVerifyResponse["hostname"].ToString().Equals("localhost"))) * {*/ //_logger.LogInformation("Verified ReCaptcha"); // Write the log entry. //_logger.LogInformation("Post Index Method"); // Add a handler to trace outgoing requests and to propagate the trace header. //indexViewViewModel.translationViewModel.TekstZaPreveduvanje = HttpUtility.HtmlEncode(indexViewViewModel.translationViewModel.TekstZaPreveduvanje); if (indexViewViewModel.selectLanguageTranslationListViewModel.SelectedPrevod.Equals("MkDe") && !String.IsNullOrEmpty(indexViewViewModel.translationViewModel.TekstZaPreveduvanje)) { //_logger.LogInformation("if MkDe"); //_logger.LogInformation("if MkDe : indexViewViewModel.translationViewModel.TekstZaPreveduvanje = " + indexViewViewModel.translationViewModel.TekstZaPreveduvanje); indexViewViewModel.translationViewModel.Makedonski = indexViewViewModel.translationViewModel.TekstZaPreveduvanje; TranslationViewModel result = await MacedonianCroatianEnglishGermanTranslation.MkCroEnDe(indexViewViewModel.translationViewModel.Makedonski, _googleCloudPlatformProjectName.Value.ProjectName, _logger, _googleTranslateApiCredentials); indexViewViewModel.translationViewModel = result; //indexViewViewModel.translationViewModel.Makedonski = HttpUtility.HtmlDecode(indexViewViewModel.translationViewModel.Makedonski); return(View("Index", indexViewViewModel)); } else if (indexViewViewModel.selectLanguageTranslationListViewModel.SelectedPrevod.Equals("DeMk") && !String.IsNullOrEmpty(indexViewViewModel.translationViewModel.TekstZaPreveduvanje)) { //_logger.LogInformation("else if DeMk"); //_logger.LogInformation("else if DeMk : indexViewViewModel.translationViewModel.TekstZaPreveduvanje = " + indexViewViewModel.translationViewModel.TekstZaPreveduvanje); indexViewViewModel.translationViewModel.Germanski = indexViewViewModel.translationViewModel.TekstZaPreveduvanje; TranslationViewModel result = await MacedonianCroatianEnglishGermanTranslation.DeEnCroMk(indexViewViewModel.translationViewModel.Germanski, _googleCloudPlatformProjectName.Value.ProjectName, _logger, _googleTranslateApiCredentials); indexViewViewModel.translationViewModel = result; //indexViewViewModel.translationViewModel.Germanski = HttpUtility.HtmlDecode(indexViewViewModel.translationViewModel.Germanski); return(View("Index", indexViewViewModel)); } /*} * else * { * ViewData["error"] = "Invalid ReCaptcha"; * }*/ return(View(new IndexViewViewModel(new TranslationViewModel(), new SelectLanguageTranslationListViewModel()))); }