Beispiel #1
0
        private static MvcHtmlString GetCommentsList(HtmlHelper helper, IDataItem item, string title)
        {
            if (SystemManager.GetModule("Comments") == null || item == null)
            {
                return(MvcHtmlString.Empty);
            }

            var itemTypeFullName = item.GetType().FullName;
            var itemProviderName = item.GetProviderName();

            var itemThreadKey = ControlUtilities.GetLocalizedKey(item.Id, null, CommentsBehaviorUtilities.GetLocalizedKeySuffix(itemTypeFullName));
            var itemGroupKey  = ControlUtilities.GetUniqueProviderKey(GetDataSourceName(item), itemProviderName);

            var routeDictionary = new System.Web.Routing.RouteValueDictionary()
            {
                { "AllowComments", GetAllowComments(item) },
                { "ThreadKey", itemThreadKey },
                { "ThreadTitle", title },
                { "ThreadType", itemTypeFullName },
                { "GroupKey", itemGroupKey },
                { "DataSource", itemProviderName }
            };

            var controllerName = itemThreadKey.EndsWith(ReviewsSuffix, StringComparison.Ordinal) ? CommentsHelpers.ReviewsControllerName : CommentsHelpers.CommentsControllerName;

            MvcHtmlString result;

            try
            {
                result = helper.Action(CommentsHelpers.IndexActionName, controllerName, routeDictionary);
            }
            catch (HttpException)
            {
                result = MvcHtmlString.Empty;
            }
            catch (NullReferenceException)
            {
                //// Telerik.Sitefinity.Mvc.SitefinityMvcRoute GetOrderedParameters() on line 116 controllerType.GetMethods() throws null reference exception (controllerType is null).
                result = MvcHtmlString.Empty;
            }

            return(result);
        }
Beispiel #2
0
        private static MvcHtmlString GetCommentsList(HtmlHelper helper, IDataItem item, string title)
        {
            if (SystemManager.GetModule("Comments") == null || item == null)
            {
                return MvcHtmlString.Empty;
            }

            var itemTypeFullName = item.GetType().FullName;
            var itemProviderName = item.GetProviderName();

            var itemThreadKey = ControlUtilities.GetLocalizedKey(item.Id, null, CommentsBehaviorUtilities.GetLocalizedKeySuffix(itemTypeFullName));
            var itemGroupKey = ControlUtilities.GetUniqueProviderKey(GetDataSourceName(item), itemProviderName);

            var routeDictionary = new System.Web.Routing.RouteValueDictionary()
            {
                { "AllowComments", GetAllowComments(item) },
                { "ThreadKey", itemThreadKey },
                { "ThreadTitle", title },
                { "ThreadType", itemTypeFullName },
                { "GroupKey", itemGroupKey },
                { "DataSource", itemProviderName }
            };

            var controllerName = itemThreadKey.EndsWith(ReviewsSuffix, StringComparison.Ordinal) ? CommentsHelpers.ReviewsControllerName : CommentsHelpers.CommentsControllerName;

            MvcHtmlString result;
            try
            {
                result = helper.Action(CommentsHelpers.IndexActionName, controllerName, routeDictionary);
            }
            catch (HttpException)
            {
                result = MvcHtmlString.Empty;
            }
            catch (NullReferenceException)
            {
                //// Telerik.Sitefinity.Mvc.SitefinityMvcRoute GetOrderedParameters() on line 116 controllerType.GetMethods() throws null reference exception (controllerType is null).
                result = MvcHtmlString.Empty;
            }

            return result;
        }