Example #1
0
        public static int GetDefaultSortOrder(int fieldIndex)
        {
            DefaultSortOrder result = DefaultSortOrder.Asc;

            callSignature = String.Format("ContentGetDefaultSortOrder ({0})", fieldIndex);
            try {
                result = Plugin.GetDefaultSortOrder(fieldIndex);

                TraceCall(TraceLevel.Info, result.ToString());
            } catch (Exception ex) {
                ProcessException(ex);
            }
            return((int)result);
        }
        public override void Process(TagHelperContext context, TagHelperOutput output)
        {
            var action     = ViewContext.RouteData.Values["action"] as string;
            var controller = ViewContext.RouteData.Values["controller"] as string;

            var sortColumn   = GetColumnFromQueryString();
            var sortOrder    = GetSortOrderFromQueryString();
            var isSortColumn = sortColumn == ColumnName || (string.IsNullOrWhiteSpace(sortColumn) && IsDefault);

            var values = new
            {
                SelectedTab = SelectedTab,
                SearchTerm  = GetSearchTermFromQueryString(),
                SortColumn  = ColumnName,
                SortOrder   = isSortColumn ? sortOrder.Reverse().ToString() : DefaultSortOrder.ToString()
            };

            var href = _urlHelper.Action(action, controller, values, null, null, null);

            var sortOrderCssSuffix = string.Empty;

            if (isSortColumn)
            {
                sortOrderCssSuffix = sortOrder == SortOrder.Ascending ? "das-table__sort--asc" : "das-table__sort--desc";
            }

            var ariaSort = sortOrder.ToString().ToLower();

            var content = new StringBuilder();

            content.Append($"<a class=\"{CssClass} {sortOrderCssSuffix}\" href=\"{href}\" aria-sort=\"{ariaSort}\">");
            content.Append(Label);
            content.Append("</a>");

            output.TagName = "";
            output.PostContent.SetHtmlContent(content.ToString());
            output.Attributes.Clear();
        }