public async Task <IActionResult> GetAccumulatedCashback([FromServices] IBoticarioService boticarioService, [FromQuery] string cpf) { try { var cashback = await boticarioService.Cashback(cpf); _logger.LogInformation($"o Usuário {User?.Identity.Name} realizou uma busca de cashback do usuario com o cpf: {cpf}."); return(Ok(cashback)); } catch (Exception ex) { _logger.LogError(ex.Message); return(BadRequest(ex)); } }
public async Task <IActionResult> GetMyAccumulatedCashback([FromServices] IUserService userService, [FromServices] IBoticarioService boticarioService) { try { var userMail = User?.Identity.Name; var user = await userService.GetByEmail(userMail); if (user != null) { var cashback = await boticarioService.Cashback(user.Cpf); _logger.LogInformation($"Cashback do usuário {userMail} é de: {cashback}."); return(Ok(cashback)); } _logger.LogInformation($"Usuário com e-mail: {userMail} não foi encontrado."); return(NotFound()); } catch (Exception ex) { _logger.LogError(ex.Message); return(BadRequest(ex)); } }