Пример #1
0
        public async Task <ValidationResult> CreateAsync(Bookmark bookmark)
        {
            if (!bookmark.IsValid())
            {
                return(new ValidationResult(false, bookmark.ValidationErrors));
            }

            var createdBookmarkId = await _bookmarkRepository.CreateAsync(bookmark);

            if (createdBookmarkId <= 0)
            {
                return(new ValidationResult(false, new ValidationError("There was an error while creating the bookmark")));
            }

            return(new ValidationResult(true));
        }
Пример #2
0
        public async Task SaveAsync(RepositoryItem context)
        {
            var items = await _repository.FindAsync(context.UserId);

            var item = items.SingleOrDefault(x => x.FullName == context.FullName);

            if (item == null)
            {
                item = new RepositoryItem()
                {
                    FullName = context.FullName,
                    Url      = context.Url,
                    UserId   = context.UserId
                };
                await _repository.CreateAsync(item);
            }
            await Task.CompletedTask;
        }