Пример #1
0
        /// <summary>
        /// Create query from current parameters for search request.
        /// </summary>
        /// <returns>Query from current parameters for search request</returns>
        public string ConfigToString()
        {
            StringBuilder builder = new StringBuilder();

            if (!string.IsNullOrWhiteSpace(Query))
            {
                builder.Append($"q={Query}");
            }

            if (Page > 0)
            {
                builder.Append($"&page={Page}");
            }

            if (OrderBy != UserListAnimeSearchSortable.NoSorting)
            {
                Guard.IsValidEnum(OrderBy, nameof(OrderBy));
                Guard.IsValidEnum(SortDirection, nameof(SortDirection));
                builder.Append($"&order_by={OrderBy.GetDescription()}");
                builder.Append($"&sort={SortDirection.GetDescription()}");

                if (OrderBy2 != UserListAnimeSearchSortable.NoSorting)
                {
                    Guard.IsValidEnum(OrderBy2, nameof(OrderBy2));
                    builder.Append($"&order_by2={OrderBy2.GetDescription()}");
                }
            }

            if (ProducerId > 0)
            {
                builder.Append($"&producer={ProducerId}");
            }

            if (Year > 0)
            {
                Guard.IsValidEnum(Season, nameof(Season));
                builder.Append($"&year={Year}");
                builder.Append($"&season={Season.GetDescription()}");
            }

            if (AiringStatus != UserListAnimeAiringStatus.NoFilter)
            {
                Guard.IsValidEnum(AiringStatus, nameof(AiringStatus));
                builder.Append($"&airing_status={AiringStatus.GetDescription()}");
            }

            // change first ampersand into question mark
            return(string.Concat("?", builder.ToString().TrimEnd('&').TrimStart('&')));
        }
Пример #2
0
        /// <summary>
        /// Create query from current parameters for search request.
        /// </summary>
        /// <returns>Query from current parameters for search request</returns>
        public string ConfigToString()
        {
            StringBuilder builder = new StringBuilder();

            if (!string.IsNullOrWhiteSpace(Query))
            {
                builder.Append($"q={Query}");
            }

            if (Page > 0)
            {
                builder.Append($"&page={Page}");
            }

            if (OrderBy != UserListMangaSearchSortable.NoSorting)
            {
                builder.Append($"&order_by={OrderBy.GetDescription()}");
                builder.Append($"&sort={SortDirection.GetDescription()}");

                if (OrderBy2 != UserListMangaSearchSortable.NoSorting)
                {
                    builder.Append($"&order_by2={OrderBy2.GetDescription()}");
                }
            }

            if (MagazineId > 0)
            {
                builder.Append($"&magazine={MagazineId}");
            }

            if (PublishingStatus != UserListMangaPublishingStatus.NoFilter)
            {
                builder.Append($"&publishing_status={PublishingStatus.GetDescription()}");
            }

            // change first ampersand into question mark
            return(string.Concat("?", builder.ToString().TrimEnd('&').TrimStart('&')));
        }