public async Task <IActionResult> Update([FromBody] UserDto userDto) { var updatedUser = await _accountService.UserUpdate(ControllerContext.GetControllerInfo(), userDto); if (!updatedUser.success) { return(this.Unauthorized()); } return(Ok(updatedUser.data)); }
public async Task <IActionResult> GetUserRoles(int userId, string roleName) { ControllerInfo ci = ControllerContext.GetControllerInfo(); var userRoles = await _accountService.UserGetRoles(userId, ci.AppName, roleName); if (userRoles == null) { return(NotFound()); } return(Ok(userRoles)); }
public async Task <IActionResult> Token([FromBody] UserDto userDto) { var user = await _accountService.UserAuthenticateGetAccessToken(ControllerContext.GetControllerInfo(), userDto.Username, userDto.Password); if (user == null) { return(BadRequest(new ApiErrorResult() { message = "Username or password is incorrect" })); } return(Ok(user)); }
public async Task <IActionResult> Create([FromBody] UserDto userDto) { var user = await _accountService.UserCreate(ControllerContext.GetControllerInfo(), userDto); if (!user.success) { return(BadRequest(new ApiErrorResult() { message = "User could not be created." })); } return(Ok(user.data)); }
public async Task <IActionResult> Token() { var ci = ControllerContext.GetControllerInfo(); var bllResult = await _accountService.UserTokenGet(ci.clientUserId, ci.AppName); if (!bllResult.success) { return(BadRequest(new ApiErrorResult() { message = "Token does not exist" })); } return(Ok(bllResult.data)); }
public async Task <IActionResult> Delete(int id) { var user = await _accountService.UserGetById(id); if (user == null) { //No user found to delete. return(NotFound()); } else { if (await _accountService.UserDeleteById(ControllerContext.GetControllerInfo(), id)) { //The user was deleted. return(Ok()); } else { //Assuming they were unauthorized to delete the user. return(this.Unauthorized()); } } }