public SearchFieldOptions(MappingListResponse response) { Kinks = response.kinks.Select(x => new Kink(x.Key, x.Value.name)).OrderBy(x => x.Name).ToList(); Genders = response.listitems.Values.Where(x => x.name == "gender").Select(x => x.value).ToList(); Roles = response.listitems.Values.Where(x => x.name == "subdom").Select(x => x.value).ToList(); Orientations = response.listitems.Values.Where(x => x.name == "orientation").Select(x => x.value).ToList(); Positions = response.listitems.Values.Where(x => x.name == "position").Select(x => x.value).ToList(); Languages = response.listitems.Values.Where(x => x.name == "languagepreference").Select(x => x.value).ToList(); FurryPrefs = response.listitems.Values.Where(x => x.name == "furrypref").Select(x => x.value).ToList(); }
internal ProfileViewModel(ProfileResponse response, MappingListResponse mappings) { Description = BbCodeParser.Parse(response.description); Views = response.views; CustomTitle = response.custom_title; CreatedAt = Helpers.UnixToDateTime(response.created_at); UpdatedAt = Helpers.UnixToDateTime(response.updated_at); var kinks = Enum.GetValues(typeof(KinkChoiceEnum)).Cast <KinkChoiceEnum>().ToDictionary(x => x, x => new LinkedList <Kink>()); var responseKinks = response.kinks.ToDictionary(x => x.Key, x => x.Value); foreach (var kink in response.custom_kinks.Values) { var subKinks = new List <Kink>(kink.children.Count); foreach (var subKink in kink.children) { responseKinks.Remove(subKink); var map = mappings.kinks[subKink]; subKinks.Add(new Kink(map.name, map.description)); } kinks[kink.choice].AddLast(new CustomKink(kink.name, kink.description, subKinks)); } foreach (var kink in responseKinks) { var map = mappings.kinks[kink.Key]; kinks[kink.Value].AddLast(new Kink(map.name, map.description)); } Kinks = kinks.ToDictionary(x => x.Key, x => (IReadOnlyCollection <Kink>)(response.customs_first ? x.Value.OrderBy(kink => kink, customsFirstComparer) : x.Value.OrderBy(kink => kink.Name)).ToList()); var info = new Dictionary <int, Dictionary <string, string> >(mappings.infotag_groups.Count); foreach (var item in response.infotags) { var mapped = mappings.infotags[item.Key]; if (!info.ContainsKey(mapped.group_id)) { info.Add(mapped.group_id, new Dictionary <string, string>()); } info[mapped.group_id].Add(mapped.name, mapped.type == MappingListResponse.InfoTagType.text ? item.Value : mappings.listitems[int.Parse(item.Value)].value); } Info = info.ToDictionary(x => mappings.infotag_groups[x.Key], x => (IReadOnlyDictionary <string, string>)x.Value); Images = response.images.OrderBy(x => x.sort_order) .Select(x => new Image($"https://static.f-list.net/images/charimage/{x.image_id}.{x.extension}", x.description)).ToList(); InlineImages = response.inlines.ToDictionary(x => x.Key, x => { var hash = x.Value.hash; return(new InlineImage($"https://static.f-list.net/images/charinline/{hash.Substring(0, 2)}/{hash.Substring(2, 2)}/{hash}.{x.Value.extension}", x.Value.nsfw)); }); }
public async Task <ProfileViewModel> GetProfile() { using (await profileSync.Lock()) { if (profile != null) { return(profile); } if (mappings == null) { mappings = (await apiManager.QueryApi("mapping-list.php")).ToObject <MappingListResponse>(); } var json = await apiManager.QueryApi("character-data.json", $"name={Character.Name}"); profile = new ProfileViewModel(json.ToObject <ProfileResponse>(), mappings); RaisePropertyChanged(nameof(Profile)); return(profile); } }