public async Task <bool> TryAddLabel(IssueReference issue, string label, DateTime at) { Validation.ValidateIssue(issue); Validation.ValidateLabel(label); bool added = await _issueLabelRepository.TrySetLabel(issue, label, true, at); if (added) { var labelSubscriptions = await _userLabelRepository.GetLabelSubscriptions(issue.RepositoryOwner, issue.RepositoryName, label); if (labelSubscriptions.Count > 0) { await _issueSubscriber.SubscribeToIssue(issue, labelSubscriptions); } } return(added); }
private async Task <LabelSubscriptionModel> SetUserSubscriptionInternal(string repositoryOwner, string repositoryName, string userId, string label) { if (userId is null) { throw new ArgumentNullException(nameof(userId)); } Validation.ValidateLabel(label); Validation.ValidateRepository(repositoryOwner, repositoryName); var labelSubscription = await _repository.SetSubscription(repositoryOwner, repositoryName, userId, label); var labelSubscriptions = new [] { labelSubscription }; foreach (var issue in await _issueQuery.SearchOpenIssuesWithLabel(repositoryOwner, repositoryName, label)) { await _issueSubscriber.SubscribeToIssue(issue, labelSubscriptions); } return(labelSubscription); }