public ActionResult CommentSection() { _logger.Debug($"{nameof(CommentSection)} has been called."); var dataSourceItem = _mvcContext.GetDataSourceItem <IComment>(); Throw.IfNull(dataSourceItem, nameof(dataSourceItem)); var model = new CommentSectionViewModel { EventId = Guid.Empty, CommentSettings = dataSourceItem }; var context = RenderingContext.CurrentOrNull; if (!(context is null)) { model.EventId = RenderingContext.Current.ContextItem.ID.Guid; } model.Comments = GetLasts(model.CommentSettings.DisplayedCommentCount, model.EventId); return(View(model)); }
public async Task <IViewComponentResult> InvokeAsync(string id) { var comments = await this.commentsService.GetAllAsync <CommentViewModel>(id); var commentArea = new CommentSectionViewModel() { Comments = comments }; return(this.View(commentArea)); }