예제 #1
0
        public async Task <IActionResult> CreateAsync([FromBody] UserRequestDto createDto)
        {
            var user = await _addUserService.AddAsync(createDto.ToUser());

            var created = UserResponseDto.FromUser(user);

            return(Created($"{_siteSettings.ListenUri}/users/{user.UserId}", created));
        }
예제 #2
0
        public async Task <IActionResult> UpdateAsync([FromRoute] Guid userId, [FromBody] UserRequestDto dto)
        {
            User user;

            if (this.UserHasScope(UserScopes.Admin) || userId == this.GetUserId())
            {
                user = await _updateUserService.UpdateAsync(dto.ToUser(userId));
            }
            else
            {
                throw new ForbiddenException();
            }

            var updated = UserResponseDto.FromUser(user);

            return(Ok(updated));
        }