public async Task <IActionResult> Cadastrar([FromForm] Disciplina d) { Disciplina disciplina = d; await _disciplinaService.Adicionar(disciplina); return(RedirectToAction("Detalhar", new { id = disciplina.Id })); }
public async Task <IActionResult> Create([Bind("Id,NomeDisciplina")] DisciplinaViewModel disciplinaViewModel) { if (!ModelState.IsValid) { return(View(disciplinaViewModel)); } var aluno = _mapper.Map <Disciplina>(disciplinaViewModel); await _disciplinaService.Adicionar(aluno); if (!OperacaoValida()) { return(View(disciplinaViewModel)); } return(RedirectToAction("Index")); }
public async Task <IActionResult> Cadastrar(DisciplinaViewModel disciplinaViewModel) { if (!ModelState.IsValid) { return(PartialView("_Cadastro", disciplinaViewModel)); } await _disciplinaService.Adicionar(disciplinaViewModel); if (!OperacaoValida) { return(PartialView("_Cadastro", disciplinaViewModel)); } TempData["Sucesso"] = "Disciplina cadastrada com sucesso!"; var url = Url.Action("ObterDisciplinas", "Disciplinas"); return(Json(new { success = true, url })); }