public async Task <IActionResult> Get() { try { return(ModelStateExtend.ToActionResult(await business.GetList())); } catch (Exception ex) { var result = new ResultMessage() { Status = "0", Message = ex.Message, Response = ex }; return(ModelStateExtend.ToActionResult(result)); } }
public async Task <IActionResult> Login([FromBody] LoginModel model) { if (!ModelState.IsValid) { return(ModelStateExtend.ToActionResultFirst(ModelState)); } var jwtToken = new JwtTokenModel() { JwtKey = configuration.GetSection("Jwt")["JwtKey"], JwtIssuer = configuration.GetSection("Jwt")["JwtIssuer"], JwtAudience = configuration.GetSection("Jwt")["JwtAudience"], JwtExpireDays = double.Parse(configuration.GetSection("Jwt")["JwtExpireDays"]) }; var result = await busines.Login(model, jwtToken); return(ModelStateExtend.ToActionResult(result)); }
public async Task <IActionResult> AddAsync([FromBody] User_Info userInfo) { try { if (!ModelState.IsValid) { return(ModelStateExtend.ToActionResultFirst(ModelState)); //return BadRequest(ModelState); } return(ModelStateExtend.ToActionResult(await business.AddAsync(userInfo as User_Info))); } catch (Exception ex) { var result = new ResultMessage() { Status = "0", Message = ex.Message, Response = ex }; return(ModelStateExtend.ToActionResult(result)); } }