public static Issuecomment ToDBIssueComment(this Octokit.IssueComment issue, Issuecomment inIssue, long repo) { inIssue.Id = issue.Id; inIssue.Body = issue.Body; inIssue.CreatedAt = issue.CreatedAt; inIssue.UpdatedAt = issue.UpdatedAt; inIssue.User = (int)(issue.User?.Id); inIssue.IssueRepository = repo; inIssue.IssueNumber = int.Parse(new Uri(issue.HtmlUrl).Segments.Last()); return(inIssue); }
public static void HandleComment(IssueComment comment, long repo) { HandleUser(comment.User); Console.WriteLine(comment.HtmlUrl); using (var db = new RFCContext()) { var existing = db.IssueComments.Where(c => c.Id == comment.Id).FirstOrDefault(); if (existing != null) { db.Entry(existing).CurrentValues.SetValues(comment.ToDBIssueComment(existing, repo)); db.SaveChanges(); } else { existing = new Issuecomment(); comment.ToDBIssueComment(existing, repo); db.IssueComments.Add(existing); db.SaveChanges(); Nag.UpdateNags(existing, repo); } } }