public void CreateAllegationComment(Guid allegationId, string comment, AllegationCommentType type, string additionalComment, Guid userId) { if (additionalComment == string.Empty) additionalComment = null; using (var context = new DatabaseContext()) { var allegation = context.Allegations.FirstOrDefault(a => a.Id == allegationId); if (allegation == null) throw new Exception(); var allegationCommentEntity = new AllegationCommentEntity { Id = Guid.NewGuid(), AllegationId = allegationId, Text = comment, AdditionalText = additionalComment, Type = type, Authorship = new Authorship { Date = DateTime.Now, UserId = userId, } }; allegation.Comments.Add(allegationCommentEntity); context.SaveChanges(); } }
private string GetAllegationActivityFeedItemDescription(AllegationCommentType type, string text, string additionalText) { if (type == AllegationCommentType.Yes) return string.Format("Yes. {0}", text); if (type == AllegationCommentType.No) return string.Format("No. {0}", text); if (type == AllegationCommentType.Advise) return string.Format("Advice. {0}\n{1}", text, additionalText); throw new ArgumentException(); }