ReviewR.Web.Services.CommentService.CreateComment C# (CSharp) Method

CreateComment() public method

public CreateComment ( int changeId, int line, string body, int userId ) : Comment
changeId int
line int
body string
userId int
return ReviewR.Web.Models.Data.Comment
        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;
        }