public IEnumerable <WeatherForecast> Get()
        {
            try
            {
                _loggerManager.LogEnter();
                _loggerManager.LogDebug("Log Debug");
                _loggerManager.LogInformation("Log info");
                _loggerManager.LogWarning("Log warning");
                int i = 5;
                int d = 0;
                //Console.WriteLine((i / d).ToString());

                var rng = new Random();
                return(Enumerable.Range(1, 5).Select(index => new WeatherForecast
                {
                    Date = DateTime.Now.AddDays(index),
                    TemperatureC = rng.Next(-20, 55),
                    Summary = Summaries[rng.Next(Summaries.Length)]
                })
                       .ToArray());
            }
            finally
            {
                _loggerManager.LogExit();
            }
        }
Exemplo n.º 2
0
        public IEnumerable <string> Get()
        {
            _logger.LogInfo("Here is info message from our values controller.");
            _logger.LogDebug("Here is debug message from our values controller.");
            _logger.LogWarning("Here is warn message from our values controller.");
            _logger.LogError("Here is error message from our values controller.");

            return(new string[] { "value1", "value2" });
        }
Exemplo n.º 3
0
        public IEnumerable <string> Get()
        {
            _logger.LogDebug("Test debug message from the controller");
            _logger.LogError("Test error message from the controller");
            _logger.LogWarning("Test warning message from the controller");
            _logger.LogInformation("Test information message from the controller");

            return(new string[] { "value1", "value2" });
        }
        public async Task <IActionResult> Login([FromBody] UserForAuthenticationDto user)
        {
            if (!await _authManager.ValidateUser(user))
            {
                _logger.LogWarning($"{nameof(Login)}: Login failed. Wrong user name or password.");
                return(Unauthorized());
                //throw new ProblemDetailsException(401, "Unauthorized");
            }

            var userFromRepo = await _userManager.FindByNameAsync(user.UserName);

            var userToReturn = _mapper.Map <UserDto>(userFromRepo);
            var token        = await _authManager.CreateToken();

            return(Ok(new { Token = token, User = userToReturn }));
        }