Пример #1
0
        public static void Initialize(TestContext context)
        {
            database = DalFactory.CreateDatabase();

            dao = DalFactory.CreateMatchDao(database);

            Assert.IsNotNull(database);

            //GenerateTestData.Data.Clear(database);
            //GenerateTestData.Data.Insert(database);
        }
 public FootballDataManager(HttpClient http = null, ITeamDao teamDao = null, IMatchDao matchDao = null,
                            ICompetitionDao competitionDao = null, IAssignmentPointManager assignmentPointManager = null)
 {
     _http             = http ?? new HttpClient();
     _http.BaseAddress = new Uri("https://api.football-data.org/v2/");
     _http.DefaultRequestHeaders.Add("X-Auth-Token", "f74e0beb5501485895a1ebb03ba925db");
     _teamDao                = teamDao ?? SingletonDao.Instance.TeamDao;
     _matchDao               = matchDao ?? SingletonDao.Instance.MatchDao;
     _competitionDao         = competitionDao ?? SingletonDao.Instance.CompetitionDao;
     _assignmentPointManager = assignmentPointManager ?? SingletonManager.Instance.AssignmentPointManager;
 }
Пример #3
0
        public HttpResponseMessage FindById(int id)
        {
            //if (Authentication.getInstance().isAuthenticateWithHeader(Request))
            //{
            IMatchDao MatchDao = DalFactory.CreateMatchDao(database);

            return(Request.CreateResponse <Match>(HttpStatusCode.OK, MatchDao.FindById(id)));
            //}
            //else
            //{
            //	return Request.CreateResponse(HttpStatusCode.Forbidden);
            //}
        }
Пример #4
0
        public HttpResponseMessage GetAgenda()
        {
            IMatchDao      MatchDao = DalFactory.CreateMatchDao(database);
            ITournamentDao to       = DalFactory.CreateTournamentDao(database);

            var list = MatchDao.FindAll();

            var listMatchIEn = list.Where(m =>
            {
                return(!m.Finished);
            });

            // MatchPaginateClass mpc = new MatchPaginateClass(list.Count, list);
            return(Request.CreateResponse <IEnumerable <Match> >(HttpStatusCode.OK, listMatchIEn));
        }
Пример #5
0
        public HttpResponseMessage GetAll()
        {
            //if (Authentication.getInstance().isAuthenticateWithHeader(Request))
            //{
            IMatchDao MatchDao = DalFactory.CreateMatchDao(database);
            var       list     = MatchDao.FindAll();

            // MatchPaginateClass mpc = new MatchPaginateClass(list.Count, list);
            return(Request.CreateResponse <IList <Match> >(HttpStatusCode.OK, list));
            //}
            //else
            //{
            //	return Request.CreateResponse(HttpStatusCode.Forbidden);
            //}
        }
Пример #6
0
 public void SetUp()
 {
     _betDao         = Substitute.For <IBetDao>();
     _teamDao        = Substitute.For <ITeamDao>();
     _matchDao       = Substitute.For <IMatchDao>();
     _betManagerMock = Substitute.For <IBetManager>();
     _betManager     = SingletonManager.Instance.SetBetManager(new BetManager(_betDao, _teamDao, _matchDao));
     _betsByUser     =
         JsonConvert.DeserializeObject <List <Bet> >(TestHelper.GetDbResponseByCollectionAndFileName("betsByUser"));
     _team           = JsonConvert.DeserializeObject <Team>(TestHelper.GetDbResponseByCollectionAndFileName("team"));
     _match          = JsonConvert.DeserializeObject <Match>(TestHelper.GetDbResponseByCollectionAndFileName("match"));
     _matchScheduled =
         JsonConvert.DeserializeObject <Match>(TestHelper.GetDbResponseByCollectionAndFileName("matchScheduled"));
     _matchesScheduled =
         JsonConvert.DeserializeObject <List <Match> >(
             TestHelper.GetDbResponseByCollectionAndFileName("matchesScheduled"));
     _bets = JsonConvert.DeserializeObject <List <Bet> >(TestHelper.GetDbResponseByCollectionAndFileName("bets"));
 }
Пример #7
0
        public void Update(Match match)
        {
            //if (Authentication.getInstance().isAuthenticateWithHeader(Request))
            //{
            IMatchDao  MatchDao  = DalFactory.CreateMatchDao(database);
            IPlayerDao PlayerDao = DalFactory.CreatePlayerDao(database);


            if (match.Finished)
            {
                Player w1;
                Player w2;
                Player v1;
                Player v2;

                if (match.ResultPointsPlayer1 > match.ResultPointsPlayer2)
                {
                    w1 = PlayerDao.FindById(match.Team1Player1);
                    w2 = PlayerDao.FindById(match.Team1Player2);
                    v1 = PlayerDao.FindById(match.Team2Player1);
                    v2 = PlayerDao.FindById(match.Team2Player2);
                }
                else
                {
                    w1 = PlayerDao.FindById(match.Team2Player1);
                    w2 = PlayerDao.FindById(match.Team2Player2);
                    v1 = PlayerDao.FindById(match.Team1Player1);
                    v2 = PlayerDao.FindById(match.Team1Player2);
                }
                BLPlayer.UpdateElo(w1, w2, v1, v2);

                BLStatistic.Insert(w1.ID, w1.Skills);
                BLStatistic.Insert(w2.ID, w2.Skills);
                BLStatistic.Insert(v1.ID, v1.Skills);
                BLStatistic.Insert(v2.ID, v2.Skills);

                PlayerDao.Update(w1);
                PlayerDao.Update(w2);
                PlayerDao.Update(v1);
                PlayerDao.Update(v2);
            }
            MatchDao.Update(match);
            //}
        }
Пример #8
0
        public HttpResponseMessage GetAllByPage(int page, int numberPerPage)
        {
            //if (Authentication.getInstance().isAuthenticateWithHeader(Request))
            //{
            IMatchDao MatchDao = DalFactory.CreateMatchDao(database);
            var       list     = MatchDao.FindAll().OrderByDescending(s => s.ID).ToList();
            var       remain   = list.Count - (page - 1) * numberPerPage;
            var       count    = remain >= numberPerPage ? numberPerPage : remain;

            var newlist            = list.ToList().GetRange(((page - 1) * numberPerPage), count).OrderBy(s => s.ID).ToList();
            MatchPaginateClass mpc = new MatchPaginateClass(list.Count, newlist);

            return(Request.CreateResponse <MatchPaginateClass>(HttpStatusCode.OK, mpc));
            //}
            //else
            //{
            //	return Request.CreateResponse(HttpStatusCode.Forbidden);
            //}
        }
Пример #9
0
        public HttpResponseMessage GenerateMatches([FromBody] MatchGenerate MatchObj)
        {
            //if (Authentication.getInstance().isAuthenticateWithHeader(Request))
            //{
            IMatchDao MatchDao = DalFactory.CreateMatchDao(database);
            ObservableCollection <Match> matchList;

            matchList = BLMatch.GenerateMatches(MatchObj.NumberOfMatches, MatchObj.chosenPlayers, MatchObj.tournamentId);
            if (BLMatch.insertMatches(matchList))
            {
                return(Request.CreateResponse <ObservableCollection <Match> >(HttpStatusCode.OK, matchList));
            }
            return(Request.CreateResponse(HttpStatusCode.Conflict));
            //}
            //else
            //{
            //	return Request.CreateResponse(HttpStatusCode.Forbidden);
            //}
        }
Пример #10
0
 public void SetUp()
 {
     _matchDao     = Substitute.For <IMatchDao>();
     _betDao       = Substitute.For <IBetDao>();
     _matchManager = SingletonManager.Instance.SetMatchManager(new MatchManager(_betDao, _matchDao));
 }
Пример #11
0
 public BetManager(IBetDao betDao = null, ITeamDao teamDao = null, IMatchDao matchDao = null)
 {
     _betDao   = betDao ?? SingletonDao.Instance.BetDao;
     _teamDao  = teamDao ?? SingletonDao.Instance.TeamDao;
     _matchDao = matchDao ?? SingletonDao.Instance.MatchDao;
 }
 public SummonerStatsBusiness(IRiotService riotService, IMatchDao matchDetailDao, IControlDao summonerMatchesControlDao)
 {
     _riotService     = riotService;
     _matchDetailDao  = matchDetailDao;
     _matchControlDao = summonerMatchesControlDao;
 }
Пример #13
0
        public IMatchDao SetMatchDao(IMatchDao matchDao)
        {
            var dynamicMatchDaoProxy = new Proxy <IMatchDao>(matchDao);

            return(MatchDao = dynamicMatchDaoProxy.GetTransparentProxy() as IMatchDao);
        }
Пример #14
0
 public MatchManager(IBetDao betDao = null, IMatchDao matchDao = null)
 {
     _betDao   = betDao ?? SingletonDao.Instance.BetDao;
     _matchDao = matchDao ?? SingletonDao.Instance.MatchDao;
 }