public async Task <JsonResult> RegExpValidation() { var input = Request.Form["Input.Number"]; var _country = Request.Cookies["Country"]; string regexExpre = ""; if (HttpContext.Session.GetString("CountryLogin") == null) { Country = await _globalService.GetDocumentByCountry(Convert.ToInt32(_country)); HttpContext.Session.SetString("CountryLogin", JsonConvert.SerializeObject(Country)); } else { Country = JsonConvert.DeserializeObject <Country>(HttpContext.Session.GetString("CountryLogin")); } foreach (var iden in Country.Identifications) { if (iden.Default.Value && iden.Discriminator == "LEGAL") { regexExpre = iden.Regexp; } } if (!Regex.Match(input, regexExpre).Success) { return(new JsonResult(false)); } else { return(new JsonResult(true)); } }
public async Task <IActionResult> OnGetAsync() { var _country = Request.Cookies["Country"]; var _discriminator = ""; var _participant = ""; int _id = Convert.ToInt32(HttpContext.Request.Query["id"]); switch (_id) { case 1: _discriminator = "LEGAL"; _participant = "DEBTOR"; break; case 2: _discriminator = "LEGAL"; _participant = "SUPPLIER"; break; case 3: _discriminator = "LEGAL"; _participant = "FACTOR"; break; case 4: _discriminator = "PERSON"; _participant = "FACTOR"; break; case 5: _discriminator = "LEGAL"; _participant = "CONFIRMANT"; break; case 6: _discriminator = "LEGAL"; _participant = "BACKOFFICE"; break; } HttpContext.Response.Cookies.Append("Discriminator", _discriminator); HttpContext.Response.Cookies.Append("Participant", _participant); try { if (HttpContext.Session.GetString("CountryLogin") == null) { Country = await _globalService.GetDocumentByCountry(Convert.ToInt32(_country)); HttpContext.Session.SetString("CountryLogin", JsonConvert.SerializeObject(Country)); } else { Country = JsonConvert.DeserializeObject <Country>(HttpContext.Session.GetString("CountryLogin")); } } catch (Exception e) { throw e; } llenarOption(_discriminator); return(Page()); }
public async Task <IActionResult> OnGetAsync(string returnUrl = null) { var _country = Request.Cookies["Country"]; var _discriminator = ""; var _participant = ""; int _id = Convert.ToInt32(HttpContext.Request.Query["id"]); if (_id < 1 || _id > 6) { return(RedirectToPage("../Index")); } switch (_id) { case 1: _discriminator = "LEGAL"; _participant = "DEBTOR"; break; case 2: _discriminator = "LEGAL"; _participant = "SUPPLIER"; break; case 3: _discriminator = "LEGAL"; _participant = "FACTOR"; break; case 4: _discriminator = "PERSON"; _participant = "FACTOR"; break; case 5: _discriminator = "LEGAL"; _participant = "CONFIRMANT"; break; case 6: _discriminator = "LEGAL"; _participant = "BACKOFFICE"; break; } HttpContext.Response.Cookies.Append("Discriminator", _discriminator); HttpContext.Response.Cookies.Append("Participant", _participant); try { if (HttpContext.Session.GetString("CountryLogin") == null || HttpContext.Session.GetString("CountryLogin") == "null") { Country = await _globalService.GetDocumentByCountry(Convert.ToInt32(_country)); HttpContext.Session.SetString("CountryLogin", JsonConvert.SerializeObject(Country)); } else { Country = JsonConvert.DeserializeObject <Country>(HttpContext.Session.GetString("CountryLogin")); } } catch (Exception e) { HttpContext.Session.Remove("CountryLogin"); return(RedirectToPage("../Index")); } if (Country == null) { ModelState.AddModelError("Number", "Datos Invalidos"); HttpContext.Session.Remove("CountryLogin"); return(RedirectToPage("../Index")); } if (Country.Id != Convert.ToInt32(_country)) { Country = await _globalService.GetDocumentByCountry(Convert.ToInt32(_country)); HttpContext.Session.SetString("CountryLogin", JsonConvert.SerializeObject(Country)); } Discriminator = _discriminator; Participant = _participant; Fill_Inputs(); if (!string.IsNullOrEmpty(ErrorMessage)) { ModelState.AddModelError(string.Empty, ErrorMessage); } returnUrl = returnUrl ?? Url.Content("~/"); // Clear the existing external cookie to ensure a clean login process await HttpContext.SignOutAsync(IdentityConstants.ExternalScheme); ExternalLogins = (await _signInManager.GetExternalAuthenticationSchemesAsync()).ToList(); ReturnUrl = returnUrl; return(Page()); }