public async Task <ActionResult <ContatoViewModel> > Adicionar(string usuarioId, ContatoViewModel contatoViewModel) { if (!ModelState.IsValid) { return(CustomResponse(ModelState)); } contatoViewModel.UserId = usuarioId; await _contatoService.Adicionar(_mapper.Map <Contato>(contatoViewModel)); return(CustomResponse(contatoViewModel)); }
public async Task <IActionResult> OnPostAsync(CancellationToken cancellationToken) { if (!ModelState.IsValid) { return(Page()); } //todo: persistir os dados var result = await _contatoService.Adicionar(Contato, cancellationToken).ConfigureAwait(false); if (!result) { return(RedirectToPage("/Error")); } return(RedirectToPage("Index")); }
public Contato Adicionar(Contato entity) { return(_contatoService.Adicionar(entity)); }