public async Task <IActionResult> OnGetAsync() { var token = HttpContext.Session.GetString("token"); if (token == null || token == "" || token == "null") { return(RedirectToPage("/logout")); } Owner = User.Claims.Where(x => x.Type == "Owner").Select(x => x.Value).SingleOrDefault(); Participant = User.Claims.Where(x => x.Type == "Participant").Select(x => x.Value).SingleOrDefault(); country = User.Claims.Where(x => x.Type == "Country").Select(x => x.Value).SingleOrDefault(); User Contrato = new User(); Contrato.Person = new Prospecto(); if (Participant == "DEBTOR") { filterInvoice PeopleId = new filterInvoice(); PeopleId.Id = Owner; var contratoTerminos = await _peopleService.ConsultaContratoAsync(new ParamProspecto { Filter = PeopleId, Country = int.Parse(country), Participant = Participant }, token); if (contratoTerminos != null && contratoTerminos.Agreements != null) { foreach (var contrato in contratoTerminos.Agreements) { Contrato.Person.Agreements.Add(contrato); } } } var data = await this._globalService.GetDataCountryInvoices(Int32.Parse(country), token); Country = data; Contrato.Participant = Participant; ContratoJson = JsonConvert.SerializeObject(Contrato); #region RefreshToken var id = User.Claims.Where(x => x.Type == "Id").Select(x => x.Value).SingleOrDefault(); var l = await this._aS.RefreshToken(id, CultureInfo.CurrentCulture.Name, "DEBTOR", token); if (l.Error == null) { HttpContext.Session.SetString("token", l.Token); } #endregion return(Page()); }
public async Task <IActionResult> OnGetAsync() { var token = HttpContext.Session.GetString("token"); if (token == null || token == "" || token == "null") { return(RedirectToPage("/logout")); } Owner = User.Claims.Where(x => x.Type == "Owner").Select(x => x.Value).SingleOrDefault(); Participant = User.Claims.Where(x => x.Type == "Participant").Select(x => x.Value).SingleOrDefault(); Country = User.Claims.Where(x => x.Type == "Country").Select(x => x.Value).SingleOrDefault(); User Contrato = new User(); Contrato.Person = new Prospecto(); #region Supplier if (Participant == "SUPPLIER") { filterInvoice PeopleId = new filterInvoice(); PeopleId.Id = Owner; var contratoTerminos = await _peopleService.ConsultaContratoAsync(new ParamProspecto { Filter = PeopleId, Country = int.Parse(Country) }, token); var Countries = await _globalService.ConsultaBanksTF(new ParamCountry { Id = int.Parse(Country) }); if (contratoTerminos != null) { foreach (var contrato in contratoTerminos.Agreements) { if (Countries.Entities != null) { foreach (var banks in Countries.Entities) { if (contrato.Entity == banks.Id && contrato.AcceptedAt == null) { Contrato.Person.Name = banks.Person.Name; } } Contrato.Person.Agreements.Add(contrato); } if (contrato.Accepted == true && contrato.Abbreviation == "MEMBERSHIP" && contrato.Participant == "SUPPLIER") { Contrato.State = "no_const"; } } } } #endregion #region RefreshToken var id = User.Claims.Where(x => x.Type == "Id").Select(x => x.Value).SingleOrDefault(); var l = await this._aS.RefreshToken(id, CultureInfo.CurrentCulture.Name, "SUPPLIER", token); if (l.Error == null) { HttpContext.Session.SetString("token", l.Token); } #endregion Contrato.Participant = Participant; Contrato.IsAuthenticated = (await _AuthorizationService.AuthorizeAsync(User, "PolicyContracts")).Succeeded; ContratoJson = JsonConvert.SerializeObject(Contrato); return(Page()); }