private void PopulateStaticData(FixtureViewModel model)
        {
            // TODO Perhaps get only the teams involved in the cup?
            if (model.Fixture.IsCupFixture)
            {
                model.Teams = teamService.GetTeamsForCurrentSeason().ToSelectList(x => x.ToString(), x => x.Id.ToString(), null);
            }
            else
            {
                model.Teams = teamService.GetTeamsForLeague(model.LeagueOrCupId).ToSelectList(x => x.ToString(), x => x.Id.ToString(), null);
            }

            if (model.Fixture.IsCupFixture)
            {
                model.LeagueOrCupName = cupService.Get(model.LeagueOrCupId).ToString();
            }
            else
            {
                model.LeagueOrCupName = competitionService.GetLeague(model.LeagueOrCupId).ToString();
            }

            model.Referees1 = refereeService.Get(orderBy: q => q.OrderBy(x => x.Forename)).ToSelectListWithHeader(x => x.ToString(), x => x.Id.ToString(), null, "None");
            model.Referees2 = refereeService.Get(orderBy: q => q.OrderBy(x => x.Forename)).ToSelectListWithHeader(x => x.ToString(), x => x.Id.ToString(), null, "None");

            model.OneOffVenues = oneOffVenueService.Get(orderBy: q => q.OrderBy(x => x.Venue)).ToSelectListWithHeader(x => x.ToString(), x => x.Id.ToString(), null, "None");
        }
示例#2
0
        public void SetCardData(FixtureViewModel fixture)
        {
            _homeTeamDetails.TeamGoals.BindingContext = fixture;
            _awayTeamDetails.TeamGoals.BindingContext = fixture;

            _homeTeamDetails.SetDetailViewData(fixture?.Fixture.HomeTeam);
            _awayTeamDetails.SetDetailViewData(fixture?.Fixture.AwayTeam);
        }
示例#3
0
 public ActionResult Index(FixtureViewModel vm)
 {
     if (ModelState.IsValid)
     {
         _fixture.UpdateFixture(ModelFactory.Create(vm));
     }
     return(View(vm));
 }
        public ActionResult Edit(int id)
        {
            FixtureViewModel model = new FixtureViewModel(fixtureService.Get(id));

            model.MapToModel(model.Fixture);

            PopulateStaticData(model);

            return(View(model));
        }
        public ActionResult Edit(List <string> session, int LeagueId, List <string> DaysSelected, DateTime StartDate, int Repeats)
        {
            Teams            league = new Teams(LeagueId);
            FixtureUtilities fu     = new FixtureUtilities();

            Fixtures fix = fu.Process(league, StartDate, session, DaysSelected, false, Repeats);


            FixtureViewModel fvm = fu.FixtureList(fix);

            return(View("Fixtures", fvm));
        }
        public ActionResult Create(int leagueOrCupId, bool isCup)
        {
            FixtureViewModel model = new FixtureViewModel();

            model.LeagueOrCupId = leagueOrCupId;

            model.Fixture.IsCupFixture = isCup;

            PopulateStaticData(model);

            return(View(model));
        }
        protected override void Handle(WeekFixtureCreatedEvent notification)
        {
            var fixture = new FixtureViewModel
            {
                FixtureId  = notification.FixtureId,
                SeasonId   = notification.SeasonId,
                StartDate  = notification.StartDate,
                EndDate    = notification.EndDate,
                DivisionId = notification.DivisionId,
                WeekNumber = notification.FixtureWeekNumber,
            };

            this.context.Add(fixture);
            this.context.SaveChanges();
        }
        public ActionResult Create(FixtureViewModel model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    model.Validate();

                    // TODO Ideally a service should do this
                    model.Fixture = model.MapToFixture(
                        model.Fixture,
                        this.competitionService.GetTeamLeagueByTeamIdInCurrentSeason(model.HomeTeamId),
                        this.competitionService.GetTeamLeagueByTeamIdInCurrentSeason(model.AwayTeamId),
                        model.Referee1Id.HasValue ? this.refereeService.Get(model.Referee1Id.Value) : null,
                        model.Referee2Id.HasValue ? this.refereeService.Get(model.Referee2Id.Value) : null,
                        this.membershipService.GetLoggedInUser(),
                        model.OneOffVenueId.HasValue ? oneOffVenueService.Get(model.OneOffVenueId.Value) : null);

                    if (model.Fixture.IsCupFixture)
                    {
                        model.Fixture.Cup = cupService.Get(model.LeagueOrCupId);
                    }

                    fixtureService.Save(model.Fixture);
                    fixtureService.Commit();

                    SuccessMessage(FormMessages.SaveSuccess);

                    if (model.CreateAnotherFixture)
                    {
                        return(RedirectToAction("Create", new { leagueOrCupId = model.LeagueOrCupId, isCup = model.Fixture.IsCupFixture }));
                    }
                    else
                    {
                        return(RedirectToAction("Index"));
                    }
                }
            }
            catch (FixtureTeamsTheSameException)
            {
                ErrorMessage(FormMessages.FixtureTeamsTheSame);
            }

            PopulateStaticData(model);

            return(View(model));
        }
示例#9
0
        public FixtureCardView(FixtureViewModel fixture)
        {
            _homeTeamDetails = new FixtureCardDetailsView(fixture?.Fixture?.HomeTeam);
            _homeTeamDetails.TeamGoals.BindingContext = fixture;
            _homeTeamDetails.TeamGoals.SetBinding(Label.TextProperty, nameof(FixtureViewModel.HomeTeamGoals));

            _awayTeamDetails = new FixtureCardDetailsView(fixture?.Fixture?.AwayTeam);
            _awayTeamDetails.TeamGoals.BindingContext = fixture;
            _awayTeamDetails.TeamGoals.SetBinding(Label.TextProperty, nameof(FixtureViewModel.AwayTeamGoals));

            Grid grid = new Grid {
                Padding         = new Thickness(1, 1, 2, 2),
                RowSpacing      = 1,
                ColumnSpacing   = 0,
                BackgroundColor = Color.FromHex("E3E3E3").MultiplyAlpha(0.5),
                VerticalOptions = LayoutOptions.FillAndExpand,
                RowDefinitions  =
                {
                    new RowDefinition {
                        Height = new GridLength(50, GridUnitType.Absolute)
                    },
                    new RowDefinition {
                        Height = new GridLength(50, GridUnitType.Absolute)
                    }
                },
                ColumnDefinitions =
                {
                    new ColumnDefinition {
                        Width = new GridLength(4, GridUnitType.Absolute)
                    },
                    new ColumnDefinition {
                        Width = new GridLength(96, GridUnitType.Star)
                    }
                }
            };

            grid.Children.Add(
                new FixtureCardStatusView()
                , 0, 1, 0, 2);

            grid.Children.Add(_homeTeamDetails, 1, 0);

            grid.Children.Add(_awayTeamDetails, 1, 1);

            Content = grid;
        }
        public ActionResult Edit(FixtureViewModel model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    model.Validate();

                    Fixture fixtureToUpdate = fixtureService.Get(model.Fixture.Id);
                    TryUpdateModel(fixtureToUpdate, "Fixture");

                    fixtureToUpdate = model.MapToFixture(
                        fixtureToUpdate,
                        this.competitionService.GetTeamLeagueByTeamIdInCurrentSeason(model.HomeTeamId),
                        this.competitionService.GetTeamLeagueByTeamIdInCurrentSeason(model.AwayTeamId),
                        model.Referee1Id.HasValue ? this.refereeService.Get(model.Referee1Id.Value) : null,
                        model.Referee2Id.HasValue ? this.refereeService.Get(model.Referee2Id.Value) : null,
                        this.membershipService.GetLoggedInUser(),
                        model.OneOffVenueId.HasValue ? oneOffVenueService.Get(model.OneOffVenueId.Value) : null);

                    fixtureService.Save(fixtureToUpdate);
                    fixtureService.Commit();

                    SuccessMessage(FormMessages.SaveSuccess);

                    return(RedirectToAction("Index"));
                }
            }
            // TODO Create some kind of parent validation exception containing error property
            catch (FixtureTeamsTheSameException)
            {
                ErrorMessage(FormMessages.FixtureTeamsTheSame);
            }
            catch (FixtureRefereesTheSameException)
            {
                ErrorMessage(FormMessages.FixtureRefereesTheSame);
            }

            PopulateStaticData(model);

            return(View(model));
        }
        public IActionResult Index(string id)
        {
            AllFixturesViewModel     fixtureViewModel = new AllFixturesViewModel();
            IList <FixtureViewModel> fixtures         = new List <FixtureViewModel>();
            var allFixtures = fixtureService.AddFixture(DateTime.Now.Date);

            if (id == null && allFixtures.result != null)
            {
                id = footballService
                     .GetLeagueByID(allFixtures.result.FirstOrDefault(l => footballService.FindLeagueByID(l.league_key)).league_key)
                     .LeagueID
                     .ToString();
            }

            fixtureService.AddFixture(DateTime.Now.Date, id);
            List <Fixture> fixtureData = footballService.GetFixture(DateTime.Now.Date, id);

            foreach (var f in fixtureData)
            {
                fixtureService.Livescore(id);

                if (footballService.GetTeamByKey(f.HomeTeamKey) == null ||
                    footballService.GetTeamByKey(f.AwayTeamKey) == null)
                {
                    standingService.AddTeams(int.Parse(id));
                    standingService.AddPlayers(int.Parse(id));
                }

                FixtureViewModel currentFixture = Mapper.Map <FixtureViewModel>(f);
                currentFixture.EventStatus = f.Status == null ? "0 - 0" : f.Status;

                fixtures.Add(currentFixture);
            }

            fixtureViewModel.LeagueName = footballService.GetLeagueByID(id).Name;
            fixtureViewModel.Countries  = footballService.GetAllCountries();
            fixtureViewModel.Leagues    = footballService.GetAllLeagues();
            fixtureViewModel.Fixtures   = fixtures.Where(f => f.HomeTeam.Badge != null && f.AwayTeam.Badge != null);

            return(View(fixtureViewModel));
        }
 public async Task<ActionResult> Index(string id = null)
 {
     FixtureViewModel vm = new FixtureViewModel();
     if (id != null)
     {
         Fixture fixture = await this.fixtureService.GetFixtureAsync(id);
         if (fixture != null)
         {
             vm.Fixture = fixture;
         }
         else
         {
             vm.Fixture = fixture = new Fixture()
             {
                 Id = id,
                 Description = "no fixture found"
             };
         }
     }
     return View(vm);
 }
 public FixtureWindow(League league)
 {
     InitializeComponent();
     DataContext = new FixtureViewModel(league);
 }
示例#14
0
 public MatchDetailPage(FixtureViewModel vm)
 {
     BindingContext = vm;
     this.SetBinding(ContentPage.TitleProperty, path: nameof(FixtureViewModel.MatchTitle));
     CreateLayout();
 }
示例#15
0
 public static FixtureModel Create(FixtureViewModel viewModel)
 {
     return(new FixtureModel {
         AwayTeam = viewModel.AwayTeam, HomeTeam = viewModel.HomeTeam
     });
 }