Esempio n. 1
0
        public async Task <IActionResult> GetJwtToken()
        {
            StringToken JWTTokenDone = null;
            //
            LevenshteinDistanceViewModel levenshteinDistanceViewModel = new LevenshteinDistanceViewModel();
            UserModel userModel = new UserModel {
                Username = "******", Password = "******", EmailAddress = "*****@*****.**"
            };

            //
            using (LevenshteinDistanceApiClient levenshteinDistanceApiClient = new LevenshteinDistanceApiClient(this.configuration))
            {
                JWTTokenDone = await levenshteinDistanceApiClient.SetJwtToken(userModel);

                if (JWTTokenDone != null)
                {
                    HttpContext.Session.SetString(accessTokenSession, JWTTokenDone.JWTToken);
                    ViewData["JWTToken"] = HttpContext.Session.GetString(accessTokenSession);
                }
            }
            return(View("Index", levenshteinDistanceViewModel));
        }
Esempio n. 2
0
        public async Task <IActionResult> GetLevenshteinDistanceResult(StringsViewModel stringsViewModel)
        {
            LevenshteinDistanceViewModel           levenshteinDistanceViewModel           = null;
            LevenshteinDistanceMatrixAndCostResult levenshteinDistanceMatrixAndCostResult = null;
            StringsModel stringsModel = null;
            string       JWTToken     = null;

            if (stringsViewModel != null)
            {
                stringsModel = new StringsModel {
                    FirstString    = stringsViewModel.FirstString
                    , SecondString = stringsViewModel.SecondString
                };
                JWTToken             = HttpContext.Session.GetString(accessTokenSession).ToString();
                ViewData["JWTToken"] = HttpContext.Session.GetString(accessTokenSession);
                using (LevenshteinDistanceApiClient levenshteinDistanceApiClient = new LevenshteinDistanceApiClient(this.configuration))
                {
                    levenshteinDistanceMatrixAndCostResult = await levenshteinDistanceApiClient.GetLevenshteinDistanceMatrixAndCostResult(stringsModel, JWTToken);
                }
                if (levenshteinDistanceMatrixAndCostResult != null)
                {
                    levenshteinDistanceViewModel = new LevenshteinDistanceViewModel
                    {
                        StringsAsCriteria = new StringsViewModel
                        {
                            FirstString    = levenshteinDistanceMatrixAndCostResult.StringsAsCriteria.FirstString
                            , SecondString = levenshteinDistanceMatrixAndCostResult.StringsAsCriteria.SecondString
                        },
                        ResultTable = new LevenshteinResultTableViewModel {
                            Cost           = levenshteinDistanceMatrixAndCostResult.Cost
                            , ResultMatrix = levenshteinDistanceMatrixAndCostResult.MatrixResult
                        }
                    };
                }
            }
            return(View("Index", levenshteinDistanceViewModel));
        }