示例#1
0
        public async Task <IActionResult> AdminLogin([FromBody] AdminLoginDto loginCreds)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var result = await _repo.AdminLogin(loginCreds.Name, loginCreds.Password);

            if (result.IsSucces)
            {
                var returnDto = new AdminReturnDto()
                {
                    Credentials = result.Content,
                    Token       = result.Message
                };

                return(Ok(returnDto));
            }

            return(Unauthorized(loginCreds));
        }