Esempio n. 1
0
        public async Task DeleteTextAsync(int id)
        {
            if (id < 1)
            {
                throw new ExceptionTypes.IncorrectIdException();
            }

            if (!await _repository.ExistAsync(id))
            {
                throw new ExceptionTypes.TextNotExistException();
            }

            await _repository.DeleteTextAsync(id);
        }
Esempio n. 2
0
        public async Task CreateBookmarkAsync(CreateBookmark createBookmark)
        {
            var textExist = await _textRepository.ExistAsync(createBookmark.TextId);

            if (!textExist)
            {
                throw new NotFoundException("TextId not found");
            }

            var userExist = await _userRepository.ExistAsync(createBookmark.UserId);

            if (!userExist)
            {
                throw new NotFoundException("UserId not found");
            }

            await _textRepository.CreateBookmarkAsync(createBookmark);
        }
Esempio n. 3
0
        // Olga, Add:
        public async Task <bool> HasTextByIdAsync(int mailingId, int textId)
        {
            if (mailingId < 1 || textId < 1)
            {
                throw new ExceptionTypes.IncorrectIdException();
            }

            if (!await _repository.ExistAsync(mailingId))
            {
                throw new ExceptionTypes.MailingNotExistException();
            }

            if (!await _textRepository.ExistAsync(textId))
            {
                throw new ExceptionTypes.TextNotExistException();
            }

            return(await _repository.HasTextByIdAsync(mailingId, textId));
        }