예제 #1
0
        public async Task <ModelGitHubIssue> EnsureGitHubIssueAsync(ModelBuild modelBuild, GitHubIssueKey issueKey, bool saveChanges)
        {
            var query = GetModelBuildQuery(modelBuild.GetBuildKey())
                        .SelectMany(x => x.ModelGitHubIssues)
                        .Where(x =>
                               x.Number == issueKey.Number &&
                               x.Organization == issueKey.Organization &&
                               x.Repository == issueKey.Repository);
            var modelGitHubIssue = await query.SingleOrDefaultAsync().ConfigureAwait(false);

            if (modelGitHubIssue is object)
            {
                return(modelGitHubIssue);
            }

            modelGitHubIssue = new ModelGitHubIssue()
            {
                Organization = issueKey.Organization,
                Repository   = issueKey.Repository,
                Number       = issueKey.Number,
                ModelBuild   = modelBuild,
            };

            Context.ModelGitHubIssues.Add(modelGitHubIssue);

            if (saveChanges)
            {
                await Context.SaveChangesAsync().ConfigureAwait(false);
            }

            return(modelGitHubIssue);
        }
예제 #2
0
        public ModelGitHubIssue AddGitHubIssue(GitHubIssueKey issueKey, ModelBuild build)
        {
            var issue = new ModelGitHubIssue()
            {
                Organization = issueKey.Organization,
                Repository   = issueKey.Repository,
                Number       = issueKey.Number,
                ModelBuild   = build,
            };

            Context.ModelGitHubIssues.Add(issue);
            return(issue);
        }