Exemple #1
0
        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));
        }
Exemple #2
0
        public void IncluirAluno(AlunoGrupoViewModel alunoGrupo)
        {
            var insertCommand = _mapper.Map <IncluirAlunoNoGrupoCommand>(alunoGrupo);

            Bus.SendCommand(insertCommand);
        }