public async Task <ActionResult <ChurrasViewModel> > Adicionar(ChurrasViewModel ChurrasViewModel) { if (!ModelState.IsValid) { return(CustomResponse(ModelState)); } await _ChurrasService.Adicionar(_mapper.Map <Churras>(ChurrasViewModel)); return(CustomResponse(ChurrasViewModel)); }
public async Task <IActionResult> Salvar(ChurrasViewModel churrasViewModel) { if (!ModelState.IsValid) { return(View(nameof(Novo))); } await clientApi.CriarChurras(churrasViewModel); toastNotification.AddSuccessToastMessage("Churras criado com sucesso!"); return(RedirectToAction(nameof(Index))); }
public async Task <ActionResult <ChurrasViewModel> > Atualizar(Guid id, ChurrasViewModel ChurrasViewModel) { if (id != ChurrasViewModel.Id) { NotificarErro("O id informado não é o mesmo que foi passado na query"); return(CustomResponse(ChurrasViewModel)); } if (!ModelState.IsValid) { return(CustomResponse(ModelState)); } await _ChurrasService.Atualizar(_mapper.Map <Churras>(ChurrasViewModel)); return(CustomResponse(ChurrasViewModel)); }
public IActionResult Novo() { var churrasViewModel = new ChurrasViewModel(); return(View(churrasViewModel)); }