Exemplo n.º 1
0
        public ActionResult Abrirresolucao(ResolucaoViewModel viewModel)
        {
            var resolucao = Mapper.Map <Resolucao>(viewModel);

            resolucao.IdAluno = viewModel.Questoes[0].IdAluno;

            using (var client = new WebClient()) {
                client.Headers.Add(HttpRequestHeader.ContentType, "application/json");
                try {
                    client.UploadString(APIUrl.ResolucaoQuestaoSalvarResolucaoAluno(), "PUT",
                                        JsonConvert.SerializeObject(resolucao));

                    return(RedirectToAction("Index"));
                } catch (WebException ex) {
                    ModelState.AddModelError(string.Empty, ex.Message);
                    return(RedirectToAction("Index"));
                }
            }
        }