Ejemplo n.º 1
0
        public ActionResult EnviarTarefaATurma(TarefaViewModel viewModel)
        {
            var tarefaMapeada = Mapper.Map <TarefaTurma>(viewModel);

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

            return(RedirectToAction("Index"));
        }