Beispiel #1
0
        public ActionResult ObterAlunos(TarefaViewModel viewModel)
        {
            using (var client = new WebClient()) {
                try {
                    var obj    = client.DownloadString(APIUrl.TurmaObterAlunos(viewModel.TurmaEscolhida, viewModel.Id));
                    var alunos = JsonConvert.DeserializeObject(obj, typeof(List <Interface.AlunoTarefa>));

                    var listaAlunoViewModel = Mapper.Map <List <AlunoTarefaViewModel> >(alunos);

                    foreach (var lista in listaAlunoViewModel)
                    {
                        lista.IdTarefa = viewModel.Id;
                    }

                    return(PartialView("_ListaAlunos", listaAlunoViewModel));
                } catch (WebException ex) {
                    ModelState.AddModelError(string.Empty, ex.Message);
                    return(null);
                }
            }
        }