public virtual Comment CreateComment(int changeId, int line, string body, int userId)
{
Requires.InRange(changeId >= 0, "changeId");
Requires.InRange(line >= 0, "line");
Requires.NotNullOrEmpty(body, "body");
Requires.InRange(userId >= 0, "userId");
FileChange chg = Data.Changes.Where(c => c.Id == changeId).FirstOrDefault();
if (chg == null)
{
return null;
}
Comment cmt = new Comment()
{
Content = body,
DiffLineIndex = line,
UserId = userId,
PostedOn = DateTime.UtcNow
};
chg.Comments.Add(cmt);
Data.SaveChanges();
return cmt;
}