Example #1
0
 private string GetPointsString(Inti_MatchPointEvent mpe)
 {
     return(String.Format("<div class='panel-body'><a href='/Match/{0}'>{1} - {2}, {3}</a></div>",
                          mpe.Inti_Match.GUID,
                          mpe.Inti_Match.HomeClubInti_Club.ShortName,
                          mpe.Inti_Match.Inti_Club.ShortName,
                          mpe.Inti_Match.MatchDate.HasValue
                              ? mpe.Inti_Match.MatchDate.Value.ToShortDateString()
                              : ""
                          ));
 }
        private void AddMatchPointEvent(IntiDataContext db, Inti_Match match, Inti_AthleteClub athleteClub, Inti_PointEvent pointEvent, int nmbrOfEvents)
        {
            for (var i = 1; i <= nmbrOfEvents; i++)
            {
                var mpe = new Inti_MatchPointEvent();
                mpe.MatchGUID       = match.GUID;
                mpe.AthleteClubGUID = athleteClub.GUID;
                mpe.PointEventGUID  = pointEvent.GUID;

                mpe.Points =
                    pointEvent.Inti_PointEventPosition.Where(
                        pep => pep.PositionGUID == athleteClub.PositionGUID).ToList()[0].Points;

                if (match.TourDay == 19 || match.TourDay == 38)
                {
                    //dubbla poäng
                    mpe.Points = mpe.Points * 2;
                }

                db.Inti_MatchPointEvent.InsertOnSubmit(mpe);
            }
        }
        protected void btnUpdateDefenderPoints_Click(object sender, EventArgs e)
        {
            //loopa de båda gridsen, om de visas
            if (MatchId != Guid.Empty)
            {
                using (var db = Global.GetConnection())
                {
                    //hämta hålla nollan poäng
                    var peCleanSheet = db.Inti_PointEvent.Single(pe => pe.GUID == new Guid(pe_CleanSheet));

                    var match = db.Inti_Match.Single(m => m.GUID == MatchId);

                    for (var i = 0; i < grdHomeDefenderPoints.Rows.Count; i++)
                    {
                        var row = grdHomeDefenderPoints.Rows[i];
                        grdHomeDefenderPoints.SelectedIndex = i;
                        var guid = new Guid(grdHomeDefenderPoints.SelectedValue.ToString());

                        var athlete = db.Inti_AthleteClub.Single(ac => ac.GUID == guid);

                        if ((row.Cells[3].FindControl("chkCleanSheet") as CheckBox).Checked)
                        {
                            var mpe = new Inti_MatchPointEvent();
                            mpe.MatchGUID       = MatchId;
                            mpe.AthleteClubGUID = guid;
                            mpe.PointEventGUID  = peCleanSheet.GUID;

                            mpe.Points =
                                peCleanSheet.Inti_PointEventPosition.Where(
                                    pep => pep.PositionGUID == athlete.PositionGUID).ToList()[0].Points;

                            if (match.TourDay == 19 || match.TourDay == 38)
                            {
                                //dubbla poäng
                                mpe.Points = mpe.Points * 2;
                            }

                            db.Inti_MatchPointEvent.InsertOnSubmit(mpe);
                        }
                    }

                    for (var i = 0; i < grdAwayDefenderPoints.Rows.Count; i++)
                    {
                        var row = grdAwayDefenderPoints.Rows[i];
                        grdAwayDefenderPoints.SelectedIndex = i;
                        var guid = new Guid(grdAwayDefenderPoints.SelectedValue.ToString());

                        var athlete = db.Inti_AthleteClub.Single(ac => ac.GUID == guid);

                        if ((row.Cells[3].FindControl("chkCleanSheet") as CheckBox).Checked)
                        {
                            var mpe = new Inti_MatchPointEvent();
                            mpe.MatchGUID       = MatchId;
                            mpe.AthleteClubGUID = guid;
                            mpe.PointEventGUID  = peCleanSheet.GUID;

                            mpe.Points =
                                peCleanSheet.Inti_PointEventPosition.Where(
                                    pep => pep.PositionGUID == athlete.PositionGUID).ToList()[0].Points;

                            if (match.TourDay == 19 || match.TourDay == 38)
                            {
                                //dubbla poäng
                                mpe.Points = mpe.Points * 2;
                            }

                            db.Inti_MatchPointEvent.InsertOnSubmit(mpe);
                        }
                    }

                    db.SubmitChanges();
                }

                SwitchStep(3);
            }
        }