예제 #1
0
        public ActionResult NovaQuestao(QuestaoViewModel viewModel)
        {
            var questao = Mapper.Map <Interface.Questao>(viewModel);

            questao.IdProfessor = Convert.ToInt32(User.Identity.Name);

            using (var client = new WebClient()) {
                client.Headers.Add(HttpRequestHeader.ContentType, "application/json");
                try {
                    client.UploadString(APIUrl.SalvarQuestao(), "POST", JsonConvert.SerializeObject(questao));
                } catch (WebException ex) {
                    ModelState.AddModelError(string.Empty, ex.Message);
                }
            }

            return(RedirectToAction("NovaQuestao"));
        }