public IActionResult Curtir(MatchViewModel matchViewModel) { try { matchViewModel.UsuarioCurtiu = User.Identity.Name; matchViewModel.UsuarioCurtido = usuario; if (!ModelState.IsValid) { return(RedirectToAction("Index")); } _matchAppService.AddMatch(matchViewModel); if (!OpIsValid()) { return(RedirectToAction("Index")); } var procurarMatch = _matchAppService.ProcurarMatch(matchViewModel.UsuarioCurtido, matchViewModel.UsuarioCurtiu); if (procurarMatch != null) { NovoMatchViewModel _novoMatchViewModel = new NovoMatchViewModel { UsuarioPrimario = procurarMatch.UsuarioCurtido, UsuarioSecundario = procurarMatch.UsuarioCurtiu }; _novoMatchAppService.AddNovoMatch(_novoMatchViewModel); AlertToast("Novo Match!!!", "Entre no chat e converse com o seu novo match!", NotificationType.Success); return(RedirectToAction("Index")); } AlertToast("Match", "Usuário curtido com sucesso!", NotificationType.Success); return(RedirectToAction("Index")); } catch (Exception ex) { return(RedirectToAction("Index")); } }
public void AddNovoMatch(NovoMatchViewModel novoMatchViewModel) { var novoMatchAddCommand = _mapper.Map <AddNovoMatchCommand>(novoMatchViewModel); _bus.SendCommand(novoMatchAddCommand); }