Ejemplo n.º 1
0
        async public Task <IActionResult> Post([FromBody] Credentials credentials)
        {
            if (!ModelState.IsValid)
            {
                throw new ArgumentException("Invalid Credentials", "credentials");
            }

            var result = await _loginService.LoginAsync(credentials);

            return(Ok(result));
        }
        async public Task <LoginResultDTO> Post([FromBody] Credentials credentials)
        {
            await ApplyMigrationsAsync(context);
            await CreateAdminAsync(serviceProvider);

            if (!ModelState.IsValid)
            {
                return(new LoginResultDTO
                {
                    Successful = false,
                    Error = "Invalid credentials"
                });
            }

            var mappedCredentials = _mapper.Map <Credentials>(credentials);
            var result            = await _loginService.LoginAsync(mappedCredentials);

            return(_mapper.Map <LoginResultDTO>(result));
        }