Ejemplo n.º 1
0
        /// <summary>
        /// Converts issue to fact or topic and saves.
        /// </summary>
        /// <param name="issue"> issue to process</param>
        public async Task ConvertIssue(Issue issue)
        {
            if (issue.IssueType == EpicIssueType)
            {
                var cat = await this.db.Topics.CountAsync(t => t.EpicKey == issue.Key);
                if (cat > 0)
                {
                    return;
                }

                this.db.Topics.Add(new Topic { Title = issue.Title, EpicKey = issue.Key });
            }
            else
            {
                var factIssue = await this.db.FactIssues.FirstOrDefaultAsync(fi => fi.IssueId == issue.Id);

                if (factIssue != null)
                {
                    this.AddFactToTopic(factIssue.FactId, issue.EpicKey);
                }
                else
                {                    
                    var topic = await this.db.Topics.FirstOrDefaultAsync(t => t.EpicKey == issue.EpicKey);
                    // topic might not exist yet
                    if (topic == null)
                    {
                        return;
                    }

                    var fact = new Fact { Text = issue.Text, Html = CommonMark.CommonMarkConverter.Convert(issue.Text)};

                    fact.AddToTopic(topic);

                    db.Facts.Add(fact);
                }
            }

            issue.Processed = true;
            await db.SaveChangesAsync();
        }
Ejemplo n.º 2
0
 public void AddFact(Fact fact)
 {
     this.AddFact(fact.Id);
 }