public async Task <ActionResult> Item(string id) { var item = await _itemDbCommand.FindAsync(id); if (item == null) { return(HttpNotFound()); } var model = Mapper.Map <ItemViewModel>(item); model.CanEdit = LogonUser.IsEntitledToEditItem(item); model.CanDelete = LogonUser.IsEntitledToDeleteItem(item); model.CanEditCollarborators = LogonUser.IsEntitledToEditItemCollaborators(item); model.CanWriteComments = LogonUser.IsEntitledToWriteComments(item); ViewBag.Title = model.DisplayTitle; var comments = await _commentDbCommand.GetByItemAsync(item); foreach (var comment in comments) { var commentModel = Mapper.Map <CommentViewModel>(comment); if (comment.User == LogonUser) { commentModel.IsCommentAuthor = true; } model.Comments.Add(commentModel); } model.NewComment = (LogonUser == null) ? new CommentEditModel() : Mapper.Map <CommentEditModel>(item.NewComment(LogonUser)); return(View("Item", model)); }