public async Task<List<CommunityMission>> GetCommunityMissions(BattlelogGame game) { var result = new List<CommunityMission>(); var uri = new Uri(_battelogUri, new Uri($"/{game.ToString().ToLower()}/communitymissions/", UriKind.Relative)); var response = await _httpClient.GetAsync(uri); var source = await response.Content.ReadAsStringAsync(); var htmlParser = new HtmlParser(); var document = await htmlParser.ParseAsync(source); var section = document.QuerySelector("#community-mission"); var rows = section.QuerySelectorAll("div.row"); if (rows != null) foreach (var row in rows) { var communityMission = new CommunityMission(); var info = row.QuerySelector("div.info"); communityMission.Name = info.QuerySelector(".community-mission-info-title").TextContent; communityMission.Description = info.QuerySelector(".description").TextContent; communityMission.Reward = row.QuerySelector(".reward").QuerySelector(".description").TextContent; var timePeriod = row.QuerySelector(".timeperiod").TextContent.Replace(" UTC", "Z"); var datetimes = timePeriod.Split(new[] {" - "}, StringSplitOptions.None); communityMission.Start = DateTimeOffset.Parse(datetimes[0]); communityMission.End = DateTimeOffset.Parse(datetimes[1]); communityMission.Game = game; result.Add(communityMission); } return result; }
public bool OnlyEndDiffer(CommunityMission other) { return string.Equals(Name, other.Name) && Start.Equals(other.Start) && Game == other.Game && !End.Equals(other.End); }
protected bool Equals(CommunityMission other) { return string.Equals(Name, other.Name) && Start.Equals(other.Start) && End.Equals(other.End) && Game == other.Game; }