コード例 #1
0
        public async Task <IActionResult> Index(string nomeAluno)
        {
            List <Aluno>        lstAlunos       = new List <Aluno>();
            List <Aluno>        lstAlunosResult = new List <Aluno>();
            Pagination          pagination      = new Pagination();
            HttpClient          client          = _api.Initial();
            HttpResponseMessage res             = await client.GetAsync("api/aluno");

            if (res.IsSuccessStatusCode)
            {
                var results = res.Content.ReadAsStringAsync().Result;
                var page    = res.Headers.GetValues("Pagination").FirstOrDefault();
                pagination = JsonConvert.DeserializeObject <Pagination>(page);
                lstAlunos  = JsonConvert.DeserializeObject <List <Aluno> >(results);
            }

            if (!string.IsNullOrEmpty(nomeAluno))
            {
                lstAlunosResult = lstAlunos.Where(l => l.NomeAluno.Contains(nomeAluno)).ToList();
            }
            else
            {
                lstAlunosResult = lstAlunos.ToList();
            }

            return(View(lstAlunosResult.ToPagedList(pagination.CurrentPage, pagination.ItemsPerPage)));
        }
コード例 #2
0
        public async Task <IActionResult> Index()
        {
            List <Perfil>       lstPerfis = new List <Perfil>();
            HttpClient          client    = _api.Initial();
            HttpResponseMessage res       = await client.GetAsync("api/perfil");

            if (res.IsSuccessStatusCode)
            {
                var results = res.Content.ReadAsStringAsync().Result;
                lstPerfis = JsonConvert.DeserializeObject <List <Perfil> >(results);
            }

            return(View(lstPerfis));
        }