// GET: api/ClientsApi
        public async Task <Object> GetAll()
        {
            res = client.GetAsync(WebConfigurationManager.AppSettings["clientsWeb"]).Result;
            res.EnsureSuccessStatusCode();

            try
            {
                if (res.IsSuccessStatusCode)
                {
                    var clientsJsonString = await res.Content.ReadAsStringAsync();

                    DataSet   dataSet   = JsonConvert.DeserializeObject <DataSet>(clientsJsonString);
                    DataTable dataTable = dataSet.Tables["clients"];

                    foreach (DataRow row in dataTable.Rows)
                    {
                        lista.Add(row);
                    }
                }

                else
                {
                    log.checkHttpStatus();
                }
            }
            catch (Exception ex)
            {
                log.LogError(ex);
                throw new VuelingException("", ex);
            }
            return(lista);
        }
예제 #2
0
        // GET: api/PoliciesApi
        public async Task <Object> GetAll()
        {
            resClients = client.GetAsync(WebConfigurationManager.AppSettings["clientsWeb"]).Result;
            resClients.EnsureSuccessStatusCode();
            resPolicies = client.GetAsync(WebConfigurationManager.AppSettings["policiesWeb"]).Result;
            resPolicies.EnsureSuccessStatusCode();

            try
            {
                if (resClients.IsSuccessStatusCode && resPolicies.IsSuccessStatusCode)
                {
                    var clientsJsonString = await resClients.Content.ReadAsStringAsync();

                    var policiesJsonString = await resPolicies.Content.ReadAsStringAsync();

                    DataSet   dataSetClients    = JsonConvert.DeserializeObject <DataSet>(clientsJsonString);
                    DataSet   dataSetPolicies   = JsonConvert.DeserializeObject <DataSet>(policiesJsonString);
                    DataTable dataTableClients  = dataSetClients.Tables["clients"];
                    DataTable dataTablePolicies = dataSetPolicies.Tables["policies"];

                    for (int i = 0; i < dataTablePolicies.Rows.Count; i++)
                    {
                        Object        oPolicies = dataTablePolicies.Rows[i]["clientId"];
                        List <Object> listaP    = new List <object>
                        {
                            oPolicies
                        };

                        for (int x = 0; x < dataTableClients.Rows.Count; i++)
                        {
                            Object        oClients = dataTableClients.Rows[i]["id"];
                            List <Object> listaC   = new List <object> {
                                oClients
                            };

                            nuevaLista.Add(new PoliciesDto(listaC, listaP));
                        }
                    }
                }
                else
                {
                    log.checkHttpStatus();
                }
            }
            catch (Exception ex) {
                log.LogError(ex);
                throw new VuelingException("", ex);
            }

            return(nuevaLista);
        }