Esempio n. 1
0
        public ActionResult UpdateFixtureEvent(string teamName, Guid fixtureId)
        {
            var targetFixture = this.fixtureService.GetById(fixtureId);
            var targetTeam    = targetFixture.HomeTeam.Name == teamName ?
                                targetFixture.HomeTeam
                : targetFixture.AwayTeam;

            var playerModels = this.playerService.GetAll(targetTeam.Id)
                               .Map <Player, UpdatingFixturePlayerViewModel>()
                               .Select(p =>
                                       new SelectListItem()
            {
                Text = string.Format("{0}. {1} {2}", p.ShirtNumber, p.FirstName, p.LastName), Value = p.Id.ToString()
            });

            var fixtureViewModel = new UpdateFixtureViewModel()
            {
                Players  = playerModels,
                Id       = fixtureId,
                TeamId   = targetTeam.Id,
                TeamName = targetTeam.Name,
            };

            return(this.PartialView(PartialViews.UpdateFixtureFormPartial, fixtureViewModel));
        }
Esempio n. 2
0
        public ActionResult UpdateFixtureEvent(Guid fixtureId, UpdateFixtureViewModel fixtureModel)
        {
            this.fixtureService
            .AddFixtureEvent(fixtureId, fixtureModel.FixtureEvent, fixtureModel.Minute, fixtureModel.PlayerId);

            this.TempData[GlobalConstants.SuccessMessage] = "Fixture has been updated!";
            return(this.RedirectToAction <ScoresController>(c => c.AvailableScores()));
        }
        public void CallFixtureServiceAddFixtureEventWithCorrectParameters_WhenPassMathodParametersAreValid()
        {
            // arrange
            var fixtureService = new Mock <IFixtureService>();
            var playerService  = new Mock <IPlayerService>();

            var controller = new UpdateFixtureController(fixtureService.Object, playerService.Object);

            var id           = Guid.NewGuid();
            var fixtureModel = new UpdateFixtureViewModel()
            {
                Id = id, PlayerId = id, FixtureEvent = FixtureEventType.Penalty, Minute = 22
            };

            // act
            controller.UpdateFixtureEvent(id, fixtureModel);

            // assert
            fixtureService.Verify(f => f.AddFixtureEvent(id, fixtureModel.FixtureEvent, fixtureModel.Minute, fixtureModel.Id), Times.Once);
        }
        public void RedirectToScoresControllerAvalableScoresAction_WhenPassMathodParametersAreValid()
        {
            // arrange
            var fixtureService = new Mock <IFixtureService>();
            var playerService  = new Mock <IPlayerService>();

            var controller = new UpdateFixtureController(fixtureService.Object, playerService.Object);

            var id           = Guid.NewGuid();
            var fixtureModel = new UpdateFixtureViewModel()
            {
                Id = id, PlayerId = id, FixtureEvent = FixtureEventType.Penalty, Minute = 22
            };

            // act
            controller.UpdateFixtureEvent(id, fixtureModel);

            // assert
            controller.WithCallTo(c => c.UpdateFixtureEvent(id, fixtureModel))
            .ShouldRedirectTo <ScoresController>(sc => sc.AvailableScores());
        }