示例#1
0
        public void MapToPlayerFixtureStats_ZeroExistingPlayersZeroPlayersInTeam_ReturnsEmptyList()
        {
            var result = model.MapToPlayerFixtureStats(new List <PlayerFixture>(), new List <Player>(), new TeamLeague(), new Fixture());

            Assert.That(result, Is.Not.Null);
            Assert.That(result.Count, Is.EqualTo(0));
        }
        public ActionResult Edit(int id)
        {
            Fixture fixture      = null;
            User    loggedInUser = membershipService.GetLoggedInUser();

            // I don't particularly like this level of role checking, but I want to reuse this controller
            // for both roles so it'll do
            if (loggedInUser.SiteAdmin)
            {
                fixture = fixtureService.Get(id);
            }
            else
            {
                fixture = fixtureService.Get(id, loggedInUser.Team.Id);
            }

            if (fixture == null)
            {
                return(RedirectToAction("Index"));
            }

            MatchResultViewModel model = new MatchResultViewModel();

            model.MapToModel(fixture);

            model.HomePlayerStats = model.MapToPlayerFixtureStats(this.statsReportingService.GetPlayerStatsForFixture(fixture.Id, fixture.HomeTeamLeague.Id), playerService.GetForTeam(fixture.HomeTeamLeague.Team.Id), fixture.HomeTeamLeague, fixture);
            model.AwayPlayerStats = model.MapToPlayerFixtureStats(this.statsReportingService.GetPlayerStatsForFixture(fixture.Id, fixture.AwayTeamLeague.Id), playerService.GetForTeam(fixture.AwayTeamLeague.Team.Id), fixture.AwayTeamLeague, fixture);

            return(View(model));
        }