public IActionResult IncluirAlunoNoGrupo(Guid idGrupo, [FromBody] string email, [FromServices] UserManager <ApplicationUser> userManager, [FromServices] SignInManager <ApplicationUser> signInManager) { if (!ModelState.IsValid) { NotifyModelStateErrors(); return(Response <AlunoGrupoViewModel>()); } var accessToken = Request.Headers["Authorization"]; var handler = new JwtSecurityTokenHandler(); var securityToken = handler.ReadJwtToken(accessToken.ToString().Replace("Bearer ", "")); ApplicationUser userIdentity = _userManager.FindByNameAsync(email).Result; var aluno = _alunoAppService.GetByUserId(userIdentity.Id); var viewModel = new AlunoGrupoViewModel() { IdGrupo = idGrupo, IdAluno = aluno.Id, EmailAluno = email }; _grupoAppService.IncluirAluno(viewModel); return(Response <AlunoGrupoViewModel>(viewModel)); }
public void IncluirAluno(AlunoGrupoViewModel alunoGrupo) { var insertCommand = _mapper.Map <IncluirAlunoNoGrupoCommand>(alunoGrupo); Bus.SendCommand(insertCommand); }