コード例 #1
0
    private void LoadMembersInfo()
    {
        //var latestHandicap = doc1.Element("Members").Elements("Member").Elements("Adjustments").Elements("Adjustment")
        //                      .Where(ee => ee.Ancestors("Member").Single().Attribute("Name").Value == cbMember.SelectedItem.Value)
        //                        .OrderByDescending(ee => DateTime.Parse(ee.Attribute("Date").Value))
        //                            .Select(ee => decimal.Parse(ee.Attribute("Handicap").Value))
        //                                .Take(1)
        //                                    .SingleOrDefault();

        decimal latestHandicap = model2.GetLatestHandicap(cbMember.SelectedItem.Value);


        //var latestDiscretionary = doc1.Element("Members").Elements("Member").Elements("DiscretionaryShots").Elements("DiscretionaryShot")
        //                            .Where(ee => ee.Ancestors("Member").Single().Attribute("Name").Value == cbMember.SelectedItem.Value)
        //                                .Where(ee => DateTime.Parse(ee.Attribute("Expires").Value) > DateTime.Now)
        //                                    .Sum(ee => decimal.Parse(ee.Attribute("Adjustment").Value));

        decimal latestDiscretionary = model2.GetLatestDiscretionary(cbMember.SelectedItem.Value);


        //var latestAdjustments = doc.Element("Fixtures")
        //                             .Elements("Fixture")
        //                                .Descendants("Adjustment")
        //                                    .Where(ee => (string)ee.Attribute("Name") == cbMember.SelectedItem.Value)
        //                                        .Where(ee => DateTime.Now < DateTime.Parse((String)ee.Ancestors("Adjustments").SingleOrDefault().Attribute("Expiry")))
        //                                            .OrderByDescending(ee => DateTime.Parse((string)ee.Ancestors("Adjustments").SingleOrDefault().Attribute("Expiry")))
        //                                                .Sum(ee => decimal.Parse((string)ee.Attribute("Adjustment")));

        decimal latestAdjustments = model.GetLatestAdjustments(cbMember.SelectedItem.Value);


        //var info = doc1.Element("Members").Elements("Member")
        //            .Where(ee => ee.Attribute("Name").Value == cbMember.SelectedItem.Value)
        //                .Select(ee => new
        //                {
        //                    club = ee.Attribute("Club").Value,
        //                    playingHandicap = latestHandicap + latestDiscretionary + latestAdjustments,
        //                    picture = ee.Attribute("Picture").Value
        //                }).SingleOrDefault();

        PlayerInfo info = model2.GetPlayerInfo(cbMember.SelectedItem.Value,
                                               latestHandicap + latestDiscretionary + latestAdjustments);

        litMembersClubValue.Text     = info.Club;
        litPlayingHandicapValue.Text = info.PlayingHandicap.ToString();
        //MemberPicture.ImageUrl = info.Picture;
        MemberPicture.Src = info.Picture;
    }