public IActionResult GetUser([FromBody] Login model) { try { var users = helperClass.GetUser(model); if (users == null) { return(NotFound()); } return(Ok(users)); } catch (Exception e) { return(BadRequest()); } }
public APIResponse GetUser([FromBody] LoginModel model) { APIResponse response = new APIResponse(); try { var user = helperClass.GetUser(model); if (user != null) { var tokenString = helperClass.GenerateJSONWebToken(user); response = new APIResponse { StatusCode = 200, user = user, Token = tokenString }; return(response); } else { response = new APIResponse { StatusCode = 404, user = null, Token = null }; return(response); } } catch (Exception e) { response = new APIResponse { StatusCode = 401, user = null, Token = null }; return(response); } }