public async Task <JsonResult> OnPostInvoices([FromBody] RequestPagination pag)
        {
            ParametersDebtorEdition Parameters = new ParametersDebtorEdition();

            var token = HttpContext.Session.GetString("token");

            var c = User.Claims.Where(x => x.Type == "Owner").Select(x => x.Value).SingleOrDefault();

            var o = User.Claims.Where(x => x.Type == "Country").Select(x => x.Value).SingleOrDefault();

            Parameters.Id          = c;
            Parameters.Country     = Int32.Parse(o);
            pag.Filter.Participant = "DEBTOR";

            pag.Order = @"
                invoices.participant, invoices.created_at desc, invoices.expiration_date desc
            ";
            pag.Group = "invoices.id, countries.id, programs.id";

            var data = await this._iS.GetInvoicesForDebtorEdition(Parameters, "Carga Manual", pag.Filter, pag.Pagination, token, pag.Order, pag.Group);

            if (data.Count == 0 || data[0].Error == null)
            {
                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);
                }
            }

            return(new JsonResult(data));
        }
Exemplo n.º 2
0
 public async Task <List <Invoices> > GetInvoicesSupplier(ParametersDebtorEdition parameters, string tipo, filterInvoice filter = null, Pagination pagination = null, string token = "", string order = null, string group = null)
 {
     try
     {
         return(await this._consumer.GetInvoicesSupplier(parameters, tipo, filter, pagination, token, order, group));
     }
     catch (Exception)
     {
         return(new List <Invoices>());
     }
 }