public Dictionary <string, string> ToQueries() { var data = new Dictionary <string, string>(); if (!string.IsNullOrWhiteSpace(Keywords)) { data.Add("keywords", Keywords); } if (!string.IsNullOrWhiteSpace(Type)) { data.Add("type", Type); } if (!string.IsNullOrWhiteSpace(Sort)) { data.Add("sort", Sort); } if (!string.IsNullOrWhiteSpace(Date)) { data.Add("date", Date); } if (Category > 0) { data.Add("category", Category.ToString()); } if (User != 0) { data.Add("user", User.ToString()); } if (Topic > 0) { data.Add("topic", Topic.ToString()); } if (Status > 0) { data.Add("status", Status.ToString()); } if (Page < 1) { Page = 1; } if (PerPage < 1) { PerPage = 20; } data.Add("page", Page.ToString()); data.Add("per_page", PerPage.ToString()); return(data); }
public string ShowingTo() { if (NoOfRecords == 0) { return(string.Empty); } if (PageNo <= 1 && PerPage >= NoOfRecords) { return(NoOfRecords.ToString() + " of "); } if (PageNo <= 1 && PerPage < NoOfRecords) { return(PerPage.ToString() + " of "); } var to = ((PageNo - 1) * PerPage) + PerPage; to = to > NoOfRecords ? NoOfRecords : to; return(to.ToString() + " of "); }
/// <summary> /// The amount of entries per page (Max 25). /// </summary> public GraphQueryArgument <int> SortQueryArgument(int value) { return(PerPage.GetQueryArgumentAndSetValue(value)); }
/// <summary> /// Takes the various properties of this instance and adds them to a <see cref="Dictionary{K,V}"/> instanced passed in, ready for sending to Flickr. /// </summary> /// <param name="parameters">The <see cref="Dictionary{K,V}"/> to add the options to.</param> public void AddToDictionary(Dictionary <string, string> parameters) { if (!string.IsNullOrEmpty(UserId)) { parameters.Add("user_id", UserId); } if (!string.IsNullOrEmpty(GroupId)) { parameters.Add("group_id", GroupId); } if (!string.IsNullOrEmpty(Text)) { parameters.Add("text", Text); } if (!string.IsNullOrEmpty(Tags)) { parameters.Add("tags", Tags); } if (TagMode != TagMode.None) { parameters.Add("tag_mode", UtilityMethods.TagModeToString(TagMode)); } if (!string.IsNullOrEmpty(MachineTags)) { parameters.Add("machine_tags", MachineTags); } if (MachineTagMode != MachineTagMode.None) { parameters.Add("machine_tag_mode", UtilityMethods.MachineTagModeToString(MachineTagMode)); } if (MinUploadDate != DateTime.MinValue) { parameters.Add("min_upload_date", UtilityMethods.DateToUnixTimestamp(MinUploadDate).ToString()); } if (MaxUploadDate != DateTime.MinValue) { parameters.Add("max_upload_date", UtilityMethods.DateToUnixTimestamp(MaxUploadDate).ToString()); } if (MinTakenDate != DateTime.MinValue) { parameters.Add("min_taken_date", UtilityMethods.DateToMySql(MinTakenDate)); } if (MaxTakenDate != DateTime.MinValue) { parameters.Add("max_taken_date", UtilityMethods.DateToMySql(MaxTakenDate)); } if (Licenses.Count != 0) { var licenseArray = new List <string>(); foreach (var license in Licenses) { licenseArray.Add(license.ToString("d")); } parameters.Add("license", String.Join(",", licenseArray.ToArray())); } if (PerPage != 0) { parameters.Add("per_page", PerPage.ToString(System.Globalization.NumberFormatInfo.InvariantInfo)); } if (Page != 0) { parameters.Add("page", Page.ToString(System.Globalization.NumberFormatInfo.InvariantInfo)); } if (Extras != PhotoSearchExtras.None) { parameters.Add("extras", ExtrasString); } if (SortOrder != PhotoSearchSortOrder.None) { parameters.Add("sort", SortOrderString); } if (PrivacyFilter != PrivacyFilter.None) { parameters.Add("privacy_filter", PrivacyFilter.ToString("d")); } if (BoundaryBox != null && BoundaryBox.IsSet) { parameters.Add("bbox", BoundaryBox.ToString()); } if (Accuracy != GeoAccuracy.None) { parameters.Add("accuracy", Accuracy.ToString("d")); } if (SafeSearch != SafetyLevel.None) { parameters.Add("safe_search", SafeSearch.ToString("d")); } if (ContentType != ContentTypeSearch.None) { parameters.Add("content_type", ContentType.ToString("d")); } if (HasGeo != null) { parameters.Add("has_geo", HasGeo.Value ? "1" : "0"); } if (Latitude != null) { parameters.Add("lat", Latitude.Value.ToString(System.Globalization.NumberFormatInfo.InvariantInfo)); } if (Longitude != null) { parameters.Add("lon", Longitude.Value.ToString(System.Globalization.NumberFormatInfo.InvariantInfo)); } if (Radius != null) { parameters.Add("radius", Radius.Value.ToString("0.00000", System.Globalization.NumberFormatInfo.InvariantInfo)); } if (RadiusUnits != RadiusUnit.None) { parameters.Add("radius_units", (RadiusUnits == RadiusUnit.Miles ? "mi" : "km")); } if (Contacts != ContactSearch.None) { parameters.Add("contacts", (Contacts == ContactSearch.AllContacts ? "all" : "ff")); } if (WoeId != null) { parameters.Add("woe_id", WoeId); } if (PlaceId != null) { parameters.Add("place_id", PlaceId); } if (IsCommons) { parameters.Add("is_commons", "1"); } if (InGallery) { parameters.Add("in_gallery", "1"); } if (IsGetty) { parameters.Add("is_getty", "1"); } if (MediaType != MediaType.None) { parameters.Add("media", UtilityMethods.MediaTypeToString(MediaType)); } if (GeoContext != GeoContext.NotDefined) { parameters.Add("geo_context", GeoContext.ToString("d")); } if (Faves) { parameters.Add("faves", "1"); } if (PersonId != null) { parameters.Add("person_id", PersonId); } if (Camera != null) { parameters.Add("camera", Camera); } if (JumpTo != null) { parameters.Add("jump_to", JumpTo); } }
public string ToQueryString() { return("page=" + PageNumber.ToString() + "&per_page=" + PerPage.ToString()); }