public ActionResult NovaTarefa(TarefaViewModel viewModel) { var tarefa = Mapper.Map <Interface.Tarefa>(viewModel); tarefa.IdProfessor = Convert.ToInt32(User.Identity.Name); using (var client = new WebClient()) { client.Headers.Add(HttpRequestHeader.ContentType, "application/json"); try { client.UploadString(APIUrl.SalvarTarefa(), "POST", JsonConvert.SerializeObject(tarefa)); } catch (WebException ex) { ModelState.AddModelError(string.Empty, ex.Message); } } return(RedirectToAction("Index")); }