BinaryStudio.ClientManager.WebUi.Controllers.InquiriesController.AddComment C# (CSharp) Method

AddComment() private method

private AddComment ( int inquiryId, string text ) : System.Web.Mvc.JsonResult
inquiryId int
text string
return System.Web.Mvc.JsonResult
        public JsonResult AddComment(int inquiryId, string text)
        {
            var inquiry = repository.Get<Inquiry>(inquiryId);
            if (inquiry == null)
            {
                throw new ModelIsNotValidException();
            }

            var comment = new Comment
            {
                Date = Clock.Now,
                Text = text
            };

            inquiry.Comments.Add(comment);
            repository.Save(inquiry);

            return Json(new {date = comment.Date, txt = comment.Text});
        }