public async Task LoadOffers(Session session) { GiftInfo.GiftAvailable = false; var result = await _profileProvider.GetOffers(session.Token); var offers = result.Offers; Offers = new XCollection<Offer>(); foreach (var offer in offers.Where(offer => offer.Campaign == 2)) { Offers.Add(offer); } PresentValidTime = DateTime.MinValue; foreach (var time in Offers.Select(offer => DateTime.ParseExact(offer.ValidTill, "yyyy-MM-dd HH:mm:ss", new CultureInfo("ru-RU"), DateTimeStyles.AssumeUniversal | DateTimeStyles.AdjustToUniversal)).Where(time => time > PresentValidTime)) { PresentValidTime = time; } var count = Offers.Count(of => of.Class == 2); if (count <= 0) return; GiftInfo.GiftAvailable = true; var giftPrice = (from offer in Offers where offer.Xml.Hidden.Present.Price > 0 select offer.Xml.Hidden.Present.Price).Concat(new double[] {99999}).Min(); GiftInfo.MinGiftPrice = giftPrice; }