public void AddComment(CommentDto item, int itemId) { if (item == null) { throw new ArgumentNullException("item", "The comment item must contain a valid instance."); } if (itemId < 1) { throw new ArgumentException("The item id must be greater than 0", "itemId"); } BlogConfigurationDto configuration = this.configurationService.GetConfiguration(); CommentStatus status = configuration.CommentSettings.EnablePremoderation ? CommentStatus.Pending : CommentStatus.IsApproved; this.commentDataService.AddComment(item, itemId, status); }
public void AddComment(CommentDto comment, int itemId, CommentStatus status) { Item item = this.Session.Load<Item>(itemId); if (item == null) { throw new DexterItemNotFoundException(itemId); } ItemComments itemComments = this.Session.Load<ItemComments>(itemId) ?? new ItemComments(); Comment domainComment = comment.MapTo<Comment>(); itemComments.AddComment(domainComment, status); this.Session.Store(itemComments); }