예제 #1
0
        public async Task <Contract.Models.User> DeleteUser(string id, bool safeDelete = true)
        {
            if (!await _userGetOperations.ExistsById(id))
            {
                throw new NotFoundException("Пользователь не найден");
            }

            return(safeDelete
                ? await _userWriteOperations.SafeDelete(id)
                : await _userWriteOperations.Delete(id));
        }
예제 #2
0
 private async Task CheckExistingUser(string userId)
 {
     if (!await _userGetOperations.ExistsById(userId))
     {
         throw new NotFoundException("Пользователь не найден");
     }
 }
예제 #3
0
        public async Task <Contract.Models.Token> CreateToken(CreateTokenDto createTokenDto)
        {
            ValidationHelper.ValidateAndThrow(createTokenDto);

            if (!await _userGetOperations.ExistsById(createTokenDto.UserId))
            {
                throw new NotFoundException("Пользователь не найден");
            }

            if (!await _sourceGetOperations.ExistsById(createTokenDto.SourceId))
            {
                throw new NotFoundException("Источник не найден");
            }

            var model = new Contract.Models.Token
            {
                Id       = Guid.NewGuid().ToString(),
                Payload  = createTokenDto.Payload,
                SourceId = createTokenDto.SourceId,
                UserId   = createTokenDto.UserId
            };

            return(await _tokenWriteOperations.Create(model));
        }