public IActionResult Delete(int id) { if (!AuthorizeUser.isMatchID(User, id)) { return(Forbid()); } _userService.Delete(id); return(Ok()); }
public IActionResult GetById(int id) { if (!AuthorizeUser.isMatchID(User, id) && !AuthorizeUser.isMatchRole(User, "admin")) { return(Forbid()); } var user = _userService.GetById(id); var userDto = _mapper.Map <UserResponse>(user); return(Ok(userDto)); }
public IActionResult Update(int id, [FromBody] UserResource userDto) { if (!AuthorizeUser.isMatchID(User, id)) { return(Forbid()); } try { _userService.Update(id, userDto); return(Ok()); } catch (AppException ex) { return(BadRequest(new { message = ex.Message })); } }