public string BuildSearchQueryString(int pageNumber)
        {
            var query  = $"/search?q={SearchTerm}";
            var paramz = new List <string>();

            if (SearchResultsType != SearchResultsType.All)
            {
                paramz.Add("t=" + SearchResultsType.ToString().ToLower());
            }

            if (pageNumber > 1)
            {
                paramz.Add("p=" + pageNumber);
            }

            if (QuerySortBy != QuerySortBy.DateCreated)
            {
                paramz.Add("s=" + QuerySortBy.ToString().ToLower());
            }

            if (QueryRange != QueryRange.Forever)
            {
                paramz.Add("r=" + QueryRange.ToString().ToLower());
            }

            if (paramz.Count == 0)
            {
                return(query);
            }

            query += "&" + string.Join('&', paramz);
            return(query);
        }
Ejemplo n.º 2
0
        public string BuildTagQueryString(QueryRange queryRange)
        {
            var query = "?";

            if (CurrentPage > 1)
            {
                query += "p=" + CurrentPage + "&";
            }

            if (QuerySortBy != QuerySortBy.DateCreated)
            {
                query += "s=" + QuerySortBy.ToString().ToLower() + "&";
            }

            query += "r=" + queryRange.ToString().ToLower();
            return(query);
        }
        public string BuildSearchQueryString(QueryRange queryRange)
        {
            var query = $"/search?q={SearchTerm}";

            if (SearchResultsType != SearchResultsType.All)
            {
                query += $"&t={SearchResultsType.ToString().ToLower()}";
            }

            if (CurrentPage > 1)
            {
                query += "&p=" + CurrentPage;
            }

            if (QuerySortBy != QuerySortBy.DateCreated)
            {
                query += "&s=" + QuerySortBy.ToString().ToLower();
            }

            query += "&r=" + queryRange.ToString().ToLower();
            return(query);
        }
Ejemplo n.º 4
0
        public static bool GetDatesOfRange(QueryRange range, DateTime?start, DateTime?end, out DateTime dtUTCStart, out DateTime dtUTCEnd)
        {
            dtUTCStart = DateTime.UtcNow;
            dtUTCEnd   = DateTime.UtcNow.AddDays(-1);

            //custom range
            if (range == QueryRange.CUSTOM)
            {
                if (start.HasValue)
                {
                    dtUTCStart = start.Value.Date;
                }

                if (end.HasValue)
                {
                    dtUTCEnd = end.Value.Date.AddHours(23).AddMinutes(59).AddSeconds(59).AddMilliseconds(999);
                }
            }
            else
            {
                switch (range)
                {
                case QueryRange.CURRENTHOUR:
                    dtUTCEnd   = DateTime.UtcNow;
                    dtUTCStart = new DateTime(dtUTCEnd.Year, dtUTCEnd.Month, dtUTCEnd.Day, dtUTCEnd.Hour, 0, 0);
                    break;

                case QueryRange.CURRENTDAY:
                    dtUTCEnd   = DateTime.UtcNow;
                    dtUTCStart = dtUTCEnd.Date;
                    break;

                case QueryRange.CURRENTWEEK:
                    dtUTCEnd   = DateTime.UtcNow;
                    dtUTCStart = dtUTCEnd.Date.StartOfWeek(DayOfWeek.Monday).Date;
                    break;

                case QueryRange.CURRENTMONTH:
                    dtUTCEnd   = DateTime.UtcNow;
                    dtUTCStart = new DateTime(dtUTCEnd.Year, dtUTCEnd.Month, 1).Date;
                    break;

                case QueryRange.CURRENTYEAR:
                    dtUTCEnd   = DateTime.UtcNow;
                    dtUTCStart = new DateTime(dtUTCEnd.Year, 1, 1).Date;
                    break;

                case QueryRange.LIVE:
                    dtUTCEnd   = DateTime.UtcNow;
                    dtUTCStart = dtUTCEnd.AddSeconds(-300);
                    break;

                case QueryRange.LAST60MINUTES:
                    dtUTCEnd   = DateTime.UtcNow;
                    dtUTCStart = dtUTCEnd.AddMinutes(-60);
                    break;

                case QueryRange.LAST24HOURS:
                    dtUTCEnd   = DateTime.UtcNow;
                    dtUTCStart = dtUTCEnd.AddHours(-24);
                    break;

                case QueryRange.LAST7DAYS:
                    dtUTCEnd   = DateTime.UtcNow;
                    dtUTCStart = dtUTCEnd.AddDays(-7);
                    break;

                case QueryRange.LAST30DAYS:
                    dtUTCEnd   = DateTime.UtcNow;
                    dtUTCStart = dtUTCEnd.AddDays(-30);
                    break;

                case QueryRange.LAST365DAYS:
                    dtUTCEnd   = DateTime.UtcNow;
                    dtUTCStart = dtUTCEnd.AddDays(-365);
                    break;

                default:
                    throw new Exception($"Unknown Range: {range.ToString()}");
                }
            }

            return(true);
        }