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));
        }
        private IActionResult TryCreate(FixtureModelIn input, string sportName)
        {
            IActionResult result;
            ICollection <EncounterDto>      added         = fixtureService.AddFixture(sportName);
            ICollection <EncounterModelOut> addedModelOut = new List <EncounterModelOut>();

            foreach (EncounterDto match in added)
            {
                addedModelOut.Add(factory.CreateModelOut(match));
            }
            result = Created("fixture-generator", addedModelOut);
            return(result);
        }
        /// <summary>
        /// the actual test
        /// </summary>
        /// <param name="fixtureService"></param>
        public void ServiceTest(IFixtureService fixtureService)
        {
            Fixture f = new Fixture();
            f.Id = "Test_" + Guid.NewGuid()
                .ToString();
            f.Description = "test fixture";
            f.Date = DateTime.Now;

            fixtureService.AddFixture(f);

            var result = fixtureService.GetFixture(f.Id);

            Assert.AreEqual(f.Id, result.Id);
            Assert.AreEqual(f.Date, result.Date);
        }
        public void ServiceTestByDate(IFixtureService fixtureService)
        {
            Fixture f = new Fixture();
            f.Id = "Test_" + Guid.NewGuid()
                .ToString();
            f.Description = "test fixture";
            f.Date = DateTime.Now;

            fixtureService.AddFixture(f);
            DateTime startDate = f.Date.AddDays(-1);
            DateTime endDate = f.Date.AddDays(+1);
            var result = fixtureService.GetFixtureByDate(startDate,endDate);

            Assert.AreEqual(f.Id, result[0].Id);
            Assert.AreEqual(f.Date, result[0].Date);
        }