public async Task DeleteAsync(Guid id) { var post = await _bookmarkRepository.GetAsync(id); var tags = await GetTagsOfPost(id); if (tags != null) { _tagRepository.DecreaseUsageCountOfTags(tags.Select(t => t.Id).ToList()); } await _bookmarkRepository.DeleteAsync(id); }
public async Task <ValidationResult> DeleteAsync(int id) { if (id <= 0) { return(new ValidationResult(false, new ValidationError("The bookmark is invalid"))); } var bookmark = await _bookmarkRepository.GetAsync(id); if (bookmark == null) { return(new ValidationResult(false, new ValidationError("The bookmark wasn't found"))); } var bookmarkWasDeleted = await _bookmarkRepository.DeleteAsync(bookmark); if (!bookmarkWasDeleted) { return(new ValidationResult(false, new ValidationError("There was an error while deleting the bookmark"))); } return(new ValidationResult(true)); }