Beispiel #1
0
        public ActionResult Edit(long id)
        {
            var match = new MatchDao().GetViewModelByID(id);

            SetStatusViewBag(match.Status);
            return(View(match));
        }
        public ActionResult Create(Match match)
        {
            if (ModelState.IsValid)
            {
                //Xử lý MetaTitle
                if (!string.IsNullOrEmpty(match.Name))
                {
                    match.MetaTitle = StringHelper.ToUnsignString(match.Name);
                }

                var userSession = (UserLogin)Session[FootballFlick.Common.CommonConstants.USER_SESSION];
                match.CreatedBy = userSession.UserName;

                var dao = new MatchDao();
                if (dao.CheckCode(match.Code) == false)
                {
                    long id = dao.Insert(match);
                    if (id > 0)
                    {
                        ViewBag.Success = "Create your match successfully";
                    }
                    else
                    {
                        ModelState.AddModelError("", "Create a new match failed.");
                    }
                }
                else
                {
                    ModelState.AddModelError("", "The Code already exists. Please try another Code.");
                }
            }
            return(View(match));
        }
Beispiel #3
0
    public IEnumerator Initialize()
    {
        currDeck = GlobalVariables.GetSelectedDeck();
        MatchDao matchDao = new MatchDao();

        matchList = matchDao.getMatchsByDeck(currDeck);



        foreach (Match match in matchList)
        {
            GameObject newMatchNumber = Instantiate(textPrefab, new Vector3(0, 0, 0), Quaternion.identity) as GameObject;
            newMatchNumber.transform.SetParent(contentParent.transform, false);
            GameObject newMatchCorrect = Instantiate(textPrefab, new Vector3(0, 0, 0), Quaternion.identity) as GameObject;
            newMatchCorrect.transform.SetParent(contentParent.transform, false);
            GameObject newMatchWrong = Instantiate(textPrefab, new Vector3(0, 0, 0), Quaternion.identity) as GameObject;
            newMatchWrong.transform.SetParent(contentParent.transform, false);
            //newDeckID.text = currDeck.ObjectId; Deck nao possui mais campo Id
            newMatchNumber.GetComponent <Text>().text  = (match.MatchNumber + 1).ToString();
            newMatchCorrect.GetComponent <Text>().text = match.CorrectPoints.ToString();
            newMatchWrong.GetComponent <Text>().text   = match.WrongPoints.ToString();
        }

        hasInitialized = true;

        return(null);
    }
Beispiel #4
0
        public void GetOneMatchByID()
        {
            MatchDao      MatchDao = new MatchDao(database);
            TestPlayerDao pdao     = new TestPlayerDao();
            TournamentDao td       = new TournamentDao(database);
            var           list     = td.FindAll();
            int           tId      = list[0].ID;

            PlayerDao pd    = new PlayerDao(database);
            var       plist = pd.FindAll();

            int p1id = plist[0].ID;
            int p2id = plist[1].ID;
            int p3id = plist[2].ID;
            int p4id = plist[3].ID;

            Match m = new Match(p1id, p2id, p3id, p4id, tId, false);

            int retValue = MatchDao.Insert(m);

            Match match = MatchDao.FindById(retValue);

            Assert.AreEqual(match.Team1Player1, p1id);
            Assert.AreEqual(match.Team1Player2, p2id);
            Assert.AreEqual(match.Team2Player1, p3id);
            Assert.AreEqual(match.Team2Player2, p4id);
            Assert.AreEqual(match.TournamentId, tId);
            Assert.IsNull(m.ResultPointsPlayer1);
            Assert.IsNull(m.ResultPointsPlayer2);
        }
Beispiel #5
0
        public void CheckDeleteById()
        {
            MatchDao      MatchDao = new MatchDao(database);
            TestPlayerDao pdao     = new TestPlayerDao();
            TournamentDao td       = new TournamentDao(database);
            var           list     = td.FindAll();
            int           tId      = list[0].ID;

            PlayerDao pd    = new PlayerDao(database);
            var       plist = pd.FindAll();

            int p1id = plist[0].ID;
            int p2id = plist[1].ID;
            int p3id = plist[2].ID;
            int p4id = plist[3].ID;

            Match m = new Match(p1id, p2id, p3id, p4id, tId, false);

            int id = MatchDao.Insert(m);

            int stat1 = MatchDao.FindAll().Count;

            MatchDao.DeleteById(id);
            int stat2 = MatchDao.FindAll().Count;


            Assert.AreEqual(stat1, stat2 + 1);
        }
Beispiel #6
0
        public void InsertMatchs()
        {
            MatchDao MatchDao = new MatchDao(database);

            TestPlayerDao pdao = new TestPlayerDao();
            TournamentDao td   = new TournamentDao(database);
            var           list = td.FindAll();
            int           tId  = list[0].ID;

            PlayerDao pd    = new PlayerDao(database);
            var       plist = pd.FindAll();

            int p1id = plist[0].ID;
            int p2id = plist[1].ID;
            int p3id = plist[2].ID;
            int p4id = plist[3].ID;

            Match m = new Match(p1id, p2id, p3id, p4id, tId, false);


            int stat1 = MatchDao.FindAll().Count;

            MatchDao.Insert(m);
            int stat2 = MatchDao.FindAll().Count;

            Assert.IsTrue(stat1 == stat2 - 1);
        }
Beispiel #7
0
        public void Update()
        {
            MatchDao MatchDao = new MatchDao(database);

            TestPlayerDao pdao = new TestPlayerDao();
            TournamentDao td   = new TournamentDao(database);
            var           list = td.FindAll();
            int           tId  = list[0].ID;

            PlayerDao pd    = new PlayerDao(database);
            var       plist = pd.FindAll();

            int p1id = plist[0].ID;
            int p2id = plist[1].ID;
            int p3id = plist[2].ID;
            int p4id = plist[3].ID;

            Match m = new Match(p1id, p2id, p3id, p4id, tId, false);

            int id = MatchDao.Insert(m);

            Assert.IsNotNull(id);

            Match n = MatchDao.FindById(id);

            n.Finished = true;
            MatchDao.Update(n);

            Assert.IsTrue(MatchDao.FindById(id).Finished);
        }
        public ActionResult LichDau(long idlich, long idcd)
        {
            var dao = new MatchDao();
            var i   = dao.ListLichThiDau(idlich, idcd);

            return(PartialView(i.ToList()));
        }
Beispiel #9
0
        public ActionResult Create(Match match)
        {
            if (ModelState.IsValid)
            {
                //Xử lý MetaTitle
                if (!string.IsNullOrEmpty(match.Name))
                {
                    match.MetaTitle = StringHelper.ToUnsignString(match.Name);
                }

                var  dao = new MatchDao();
                long id  = dao.Insert(match);
                if (id > 0)
                {
                    SetAlert("Create a new match successfully.", "success");
                    return(RedirectToAction("Index", "Match"));
                }
                else
                {
                    ModelState.AddModelError("", "Create a new match failed.");
                    return(RedirectToAction("Create", "Match"));
                }
            }
            SetStatusViewBag();
            return(View(match));
        }
        public ActionResult hienthiLichDau(long id)
        {
            var dao = new MatchDao();
            var i   = dao.GetByIDLich(id);

            return(PartialView(i));
        }
        public ActionResult Statistic(long id)
        {
            var detail = new MatchDetailDao().ListMatchDetailViewModel(id);
            var match  = new MatchDao().GetByID(id);;

            ViewBag.Match = match;
            return(View(detail));
        }
Beispiel #12
0
        public IActionResult Post(Match match)
        {
            var dao = new MatchDao(Context);

            dao.Add(match);
            Context.SaveChanges();
            return(Ok());
        }
Beispiel #13
0
        public void GetOneDayByIDError()
        {
            MatchDao MatchDao = new MatchDao(database);

            MatchDao.DeleteAll();

            Assert.IsNull(MatchDao.FindById(1));
        }
Beispiel #14
0
        ////Display, create, edit, delete Match
        //Index page of Match management
        public ActionResult Index(string searchString, int page = 1, int pageSize = 10)
        {
            var dao   = new MatchDao();
            var model = dao.ListAllPaging(searchString, page, pageSize);

            ViewBag.SearchString = searchString;
            ViewBag.PageSize     = pageSize;
            return(View(model));
        }
Beispiel #15
0
        public void InsertMatches()
        {
            MatchDao dao = new MatchDao(database);

            foreach (Match m in dataSource.GenerateMatchs())
            {
                dao.Insert(m);
            }
        }
Beispiel #16
0
    public static IEnumerator InitializeGame()
    {
        //Making query
        PlayerDao    playerDao    = new PlayerDao();
        StoreDeckDao storeDeckDao = new StoreDeckDao();
        MatchDao     matchDao     = new MatchDao();

        List <Dao> daoList = new List <Dao>()
        {
            playerDao, storeDeckDao, matchDao
        };

        yield return(makeQuerry(daoList));

        if (!succsesfull)
        {
            yield break;
        }

        //Getting results
        Player player = playerDao.getQueryResultPlayer();

        Player.setInstance(player);

        List <StoreDeck> storeDeckList = storeDeckDao.getQueryResultStoreDeckList();


        bool          change = false;
        DeckBuilder   deckBuilder;
        Deck          deck;
        List <string> playerStoreDecks = player.StoreDeckNameList.getList();

        foreach (StoreDeck storeDeck in storeDeckList)
        {
            if (!playerStoreDecks.Contains(storeDeck.DeckName))
            {
                if (player.IsPremium)
                {
                    deckBuilder = new DeckBuilder(storeDeck);
                    deck        = deckBuilder.getDeck();
                    player.addDeck(deck);
                    player.addToStoreDeckNameList(deck.DeckName);
                    change = true;
                }
                else
                {
                    Store.addDeck(storeDeck);
                }
            }
        }

        if (change)
        {
            playerDao.savePlayer(player);
        }
    }
        //Display the Match and its detail
        public ActionResult Detail(long id)
        {
            var match         = new MatchDao().GetViewModelByID(id);
            var listDetail    = new MatchDetailDao().ListMatchDetailViewModel(id);
            var recentMatches = new MatchDao().ListRecentMatch(10);

            ViewBag.ListDetail    = listDetail;
            ViewBag.RecentMatches = recentMatches;
            return(View(match));
        }
Beispiel #18
0
        public ActionResult Delete(long id)
        {
            MatchDao       matchDao  = new MatchDao();
            MatchDetailDao detailDao = new MatchDetailDao();
            Match          match     = matchDao.GetByID(id);
            bool           res       = matchDao.Delete(id);
            bool           resDetail = detailDao.DeleteAll(match.ID);

            return(RedirectToAction("Index"));
        }
Beispiel #19
0
        public void GetAllMatchs()
        {
            MatchDao MatchDao = new MatchDao(database);

            int stat1 = MatchDao.FindAll().Count;

            InsertMatchs();
            int stat2 = MatchDao.FindAll().Count;

            Assert.AreEqual(stat1, stat2 - 1);
        }
Beispiel #20
0
    private void saveMatch()
    {
        //Saving match
        Match match = new Match();

        match.CorrectPoints = GlobalVariables.correctAnswerAmount;
        match.WrongPoints   = GlobalVariables.wrongAnswerAmount;
        match.DeckName      = GlobalVariables.GetSelectedDeck().DeckName;
        match.MatchNumber   = GlobalVariables.GetSelectedDeck().TimesPlayed - 1;
        MatchDao matchDao = new MatchDao();

        StartCoroutine(matchDao.saveMatch(match));
    }
Beispiel #21
0
    private IEnumerator matchDaoTeste()
    {
        yield return makeConnection();

        MatchDao matchDao = new MatchDao();
        //yield return matchDao.MakeQueryGetMatchList();

        foreach(Match match in matchDao.getMatchList())
        {
            Debug.Log(match.DeckName + ": " +  match.MatchNumber);
        }
        
    }
Beispiel #22
0
    private IEnumerator matchDaoTeste()
    {
        yield return(makeConnection());

        MatchDao matchDao = new MatchDao();

        //yield return matchDao.MakeQueryGetMatchList();

        foreach (Match match in matchDao.getMatchList())
        {
            Debug.Log(match.DeckName + ": " + match.MatchNumber);
        }
    }
Beispiel #23
0
    public static IEnumerator InitializeGame()
    {
        //Making query
        PlayerDao playerDao = new PlayerDao();
        StoreDeckDao storeDeckDao = new StoreDeckDao();
        MatchDao matchDao = new MatchDao();

        List<Dao> daoList = new List<Dao>() { playerDao, storeDeckDao,  matchDao };
        yield return makeQuerry(daoList);

        if (!succsesfull)
            yield break;

        //Getting results
        Player player = playerDao.getQueryResultPlayer();
        Player.setInstance(player);

        List<StoreDeck> storeDeckList = storeDeckDao.getQueryResultStoreDeckList();


        bool change = false;
        DeckBuilder deckBuilder;
        Deck deck;
        List<string> playerStoreDecks = player.StoreDeckNameList.getList();
        foreach (StoreDeck storeDeck in storeDeckList)
        {
            if (!playerStoreDecks.Contains(storeDeck.DeckName))
            {
                if (player.IsPremium)
                {
                    deckBuilder = new DeckBuilder(storeDeck);
                    deck = deckBuilder.getDeck();
                    player.addDeck(deck);
                    player.addToStoreDeckNameList(deck.DeckName);
                    change = true;
                }
                else
                {
                    Store.addDeck(storeDeck);
                }
            }
        }

        if (change)
        {
            playerDao.savePlayer(player);
        }

    }
Beispiel #24
0
        public static void Clear(IDatabase database)
        {
            PlayerDao     p = new PlayerDao(database);
            TournamentDao t = new TournamentDao(database);
            MatchDao      m = new MatchDao(database);
            StatisticDao  s = new StatisticDao(database);

            s.DeleteAll();
            Console.WriteLine("cleared statistics...");
            m.DeleteAll();
            Console.WriteLine("cleared matches...");
            t.DeleteAll();
            Console.WriteLine("cleared Tournaments...");
            p.DeleteAll();
            Console.WriteLine("cleared player...");
        }
Beispiel #25
0
        public ActionResult Edit(MatchViewModel matchViewModel)
        {
            Match match = new Match();

            if (ModelState.IsValid)
            {
                match.ID                = matchViewModel.ID;
                match.Code              = matchViewModel.Code;
                match.Name              = matchViewModel.Name;
                match.Description       = matchViewModel.Description;
                match.Image             = matchViewModel.Image;
                match.HomeClubID        = matchViewModel.HomeClubID;
                match.VisitingClubID    = matchViewModel.VisitingClubID;
                match.StadiumID         = matchViewModel.StadiumID;
                match.Date              = matchViewModel.Date;
                match.ExpectedStartTime = matchViewModel.ExpectedStartTime;
                match.ExpectedEndTime   = matchViewModel.ExpectedEndTime;
                match.HoldAddress       = matchViewModel.HoldAddress;
                match.Price             = matchViewModel.Price;
                match.PromotionPrice    = matchViewModel.PromotionPrice;
                match.ExpiredDateToSign = matchViewModel.ExpiredDateToSign;
                match.Detail            = matchViewModel.Detail;
                match.RealStartTime     = matchViewModel.RealStartTime;
                match.RealEndTime       = matchViewModel.RealEndTime;
                match.HomeClubGoal      = matchViewModel.HomeClubGoal;
                match.VisitingClubGoal  = matchViewModel.VisitingClubGoal;
                match.Status            = matchViewModel.Status;
                match.MetaKeywords      = matchViewModel.MetaKeywords;
                match.MetaDescriptions  = matchViewModel.MetaDescriptions;
                if (!string.IsNullOrEmpty(match.Name))
                {
                    match.MetaTitle = StringHelper.ToUnsignString(match.Name);
                }

                var result = new MatchDao().Update(match);
                if (result)
                {
                    SetAlert("Edit this match successfully.", "success");
                }
                else
                {
                    ModelState.AddModelError("", "Edit this match failed.");
                }
            }
            SetStatusViewBag(matchViewModel.Status);
            return(View(matchViewModel));
        }
        // GET: Match
        public ActionResult Index(int?matchStatus, string searchString, int pageIndex = 1, int pageSize = 10)
        {
            int totalRecord = 0;
            var model       = new MatchDao().ListAll(matchStatus, searchString, ref totalRecord, pageIndex, pageSize);

            ViewBag.SearchString = searchString;

            StatusCategory selectedMatchStatus = new StatusCategory()
            {
                Stt = 0, Name = "---Select one---"
            };

            if (matchStatus != null)
            {
                selectedMatchStatus = new StatusCategoryDao().GetByStt("Match", (int)matchStatus);
            }
            ViewBag.SelectedMatchStatus = selectedMatchStatus;

            ViewBag.Total = totalRecord;
            ViewBag.Page  = pageIndex;

            int maxPage   = 5;
            int totalPage = 0;

            if (totalRecord % pageSize != 0)
            {
                totalPage = (int)(totalRecord / pageSize) + 1;
            }
            else
            {
                totalPage = (int)(totalRecord / pageSize);
            }

            ViewBag.TotalPage = totalPage;
            ViewBag.MaxPage   = maxPage;
            ViewBag.First     = 1;
            ViewBag.Last      = totalPage;
            ViewBag.Next      = pageIndex + 1;
            ViewBag.Prev      = pageIndex - 1;

            return(View(model));
        }
	public IEnumerator Initialize(){
        currDeck = GlobalVariables.GetSelectedDeck();
		MatchDao matchDao = new MatchDao();        
		List<Match> matchList = matchDao.getMatchsByDeck(currDeck);
        GlobalVariables.matchHistory = matchList;

		/*foreach(Match match in matchList){
            Debug.Log(match.MatchNumber);
			
            GameObject newMatchCorrect = Instantiate(textPrefab, new Vector3(0,0,0), Quaternion.identity) as GameObject;
			newMatchCorrect.transform.SetParent(contentParent.transform, false);
            GameObject newMatchWrong = Instantiate(textPrefab, new Vector3(0,0,0), Quaternion.identity) as GameObject;
			newMatchWrong.transform.SetParent(contentParent.transform, false);
			newMatchCorrect.GetComponent<Text>().text = match.CorrectPoints.ToString();
			newMatchWrong.GetComponent<Text>().text = match.WrongPoints.ToString();
		}*/

		hasInitialized = true;

        return null;
	}
        //Dislay all information about the Club
        public ActionResult Detail(long id, int pageIndex = 1, int pageSize = 10)
        {
            var club      = new ClubDao().GetViewModelByID(id);
            var rankInfor = new ClubDao().DisplayRankedClub(id);

            ViewBag.RankInfor = rankInfor;

            //Liệt kê danh sách các Player của Club
            var listPlayer = new ClubPlayerDao().ListClubPlayer(id);

            ViewBag.ListPlayer = listPlayer;

            //Phân trang cho bảng liệt kê các Matches
            int totalRecord = 0;
            var listMatch   = new MatchDao().ListMatchesOftheClub(id, ref totalRecord, pageIndex, pageSize);

            ViewBag.ListMatch = listMatch;
            ViewBag.Total     = totalRecord;
            ViewBag.Page      = pageIndex;
            int maxPage   = 5;
            int totalPage = 0;

            if (totalRecord % pageSize != 0)
            {
                totalPage = (int)(totalRecord / pageSize) + 1;
            }
            else
            {
                totalPage = (int)(totalRecord / pageSize);
            }

            ViewBag.TotalPage = totalPage;
            ViewBag.MaxPage   = maxPage;
            ViewBag.First     = 1;
            ViewBag.Last      = totalPage;
            ViewBag.Next      = pageIndex + 1;
            ViewBag.Prev      = pageIndex - 1;

            return(View(club));
        }
Beispiel #29
0
        public void SetUp()
        {
            _database   = Substitute.For <IMongoDatabase>();
            _collection = Substitute.For <IMongoCollection <Match> >();
            _matchDao   = new MatchDao(_database, _collection);

            _team1 = new Team
            {
                Name    = "test", Email = "test", ShortName = "test", Tla = "test", CrestUrl = "test",
                Address = "test", Phone = "test", Colors = "test", Venue = "test"
            };
            _team2 = new Team
            {
                Name    = "test", Email = "test", ShortName = "test", Tla = "test", CrestUrl = "test",
                Address = "test", Phone = "test", Colors = "test", Venue = "test"
            };
            _fullTime = new FullTime {
                AwayTeam = 1, HomeTeam = 1
            };
            _halfTime = new HalfTime {
                AwayTeam = 1, HomeTeam = 1
            };
            _extraTime = new ExtraTime {
                AwayTeam = 1, HomeTeam = 1
            };
            _penalties = new Penalties {
                AwayTeam = 1, HomeTeam = 1
            };
            _score = new Score
            {
                Winner = "test", Duration = "test", ExtraTime = _extraTime, FullTime = _fullTime, Penalties = _penalties
            };

            _match = new Match
            {
                Status = "test", LastUpdated = DateTime.Now, HomeTeam = _team1, AwayTeam = _team2,
                Score  = _score
            };
        }
Beispiel #30
0
    public IEnumerator Initialize()
    {
        currDeck = GlobalVariables.GetSelectedDeck();
        MatchDao     matchDao  = new MatchDao();
        List <Match> matchList = matchDao.getMatchsByDeck(currDeck);

        GlobalVariables.matchHistory = matchList;

        /*foreach(Match match in matchList){
         * Debug.Log(match.MatchNumber);
         *
         * GameObject newMatchCorrect = Instantiate(textPrefab, new Vector3(0,0,0), Quaternion.identity) as GameObject;
         *      newMatchCorrect.transform.SetParent(contentParent.transform, false);
         * GameObject newMatchWrong = Instantiate(textPrefab, new Vector3(0,0,0), Quaternion.identity) as GameObject;
         *      newMatchWrong.transform.SetParent(contentParent.transform, false);
         *      newMatchCorrect.GetComponent<Text>().text = match.CorrectPoints.ToString();
         *      newMatchWrong.GetComponent<Text>().text = match.WrongPoints.ToString();
         * }*/

        hasInitialized = true;

        return(null);
    }
Beispiel #31
0
    public IEnumerator Initialize()
    {
        currDeck = GlobalVariables.GetSelectedDeck();
        MatchDao matchDao = new MatchDao();
        matchList = matchDao.getMatchsByDeck(currDeck);



        foreach (Match match in matchList)
        {
            GameObject newMatchNumber = Instantiate(textPrefab, new Vector3(0, 0, 0), Quaternion.identity) as GameObject;
            newMatchNumber.transform.SetParent(contentParent.transform, false);
            GameObject newMatchCorrect = Instantiate(textPrefab, new Vector3(0, 0, 0), Quaternion.identity) as GameObject;
            newMatchCorrect.transform.SetParent(contentParent.transform, false);
            GameObject newMatchWrong = Instantiate(textPrefab, new Vector3(0, 0, 0), Quaternion.identity) as GameObject;
            newMatchWrong.transform.SetParent(contentParent.transform, false);
            //newDeckID.text = currDeck.ObjectId; Deck nao possui mais campo Id
            newMatchNumber.GetComponent<Text>().text = (match.MatchNumber + 1).ToString();
            newMatchCorrect.GetComponent<Text>().text = match.CorrectPoints.ToString();
            newMatchWrong.GetComponent<Text>().text = match.WrongPoints.ToString();
        }

        hasInitialized = true;

        return null;
    }
Beispiel #32
0
        public ActionResult Result(MatchViewModel matchViewModel)
        {
            Match match = new Match();

            if (ModelState.IsValid)
            {
                //Update kết quả của Match
                match.ID                = matchViewModel.ID;
                match.Code              = matchViewModel.Code;
                match.Name              = matchViewModel.Name;
                match.Description       = matchViewModel.Description;
                match.Image             = matchViewModel.Image;
                match.HomeClubID        = matchViewModel.HomeClubID;
                match.VisitingClubID    = matchViewModel.VisitingClubID;
                match.StadiumID         = matchViewModel.StadiumID;
                match.Date              = matchViewModel.Date;
                match.ExpectedStartTime = matchViewModel.ExpectedStartTime;
                match.ExpectedEndTime   = matchViewModel.ExpectedEndTime;
                match.HoldAddress       = matchViewModel.HoldAddress;
                match.Price             = matchViewModel.Price;
                match.PromotionPrice    = matchViewModel.PromotionPrice;
                match.ExpiredDateToSign = matchViewModel.ExpiredDateToSign;
                match.Detail            = matchViewModel.Detail;
                match.RealStartTime     = matchViewModel.RealStartTime;
                match.RealEndTime       = matchViewModel.RealEndTime;
                match.HomeClubGoal      = matchViewModel.HomeClubGoal;
                match.VisitingClubGoal  = matchViewModel.VisitingClubGoal;
                match.Status            = matchViewModel.Status;
                match.MetaKeywords      = matchViewModel.MetaKeywords;
                match.MetaDescriptions  = matchViewModel.MetaDescriptions;
                if (!string.IsNullOrEmpty(match.Name))
                {
                    match.MetaTitle = StringHelper.ToUnsignString(match.Name);
                }

                var result = new MatchDao().Update(match);
                if (result)
                {
                    SetAlert("Result this match successfully.", "success");
                }
                else
                {
                    ModelState.AddModelError("", "Result this match failed.");
                }

                //Update ClubPoint cho cả hai đội
                ClubPoint homePoint = new ClubPoint();
                homePoint.MatchID   = match.ID;
                homePoint.ClubID    = (long)match.HomeClubID;
                homePoint.JoinPoint = CommonConstants.JoinPoint;
                homePoint.WinPoint  = (match.HomeClubGoal > match.VisitingClubGoal == true ? CommonConstants.WinPoint : 0);
                homePoint.DrawPoint = (match.HomeClubGoal == match.VisitingClubGoal == true ? CommonConstants.DrawPoint : 0);
                homePoint.Status    = true;

                ClubPoint visitingPoint = new ClubPoint();
                visitingPoint.MatchID   = match.ID;
                visitingPoint.ClubID    = (long)match.VisitingClubID;
                visitingPoint.JoinPoint = CommonConstants.JoinPoint;
                visitingPoint.WinPoint  = (match.VisitingClubGoal > match.HomeClubGoal == true ? CommonConstants.WinPoint : 0);
                visitingPoint.DrawPoint = (match.VisitingClubGoal == match.HomeClubGoal == true ? CommonConstants.DrawPoint : 0);
                visitingPoint.Status    = true;

                var homeLevel     = new ClubLevelDao().GetBeforeDate(homePoint.ClubID, (DateTime)match.Date);
                var visitingLevel = new ClubLevelDao().GetBeforeDate(visitingPoint.ClubID, (DateTime)match.Date);
                homePoint.RivalLevelID     = visitingLevel.LevelID;
                visitingPoint.RivalLevelID = homeLevel.LevelID;

                var dao = new ClubPointDao();

                if (dao.CheckExist(homePoint.MatchID, homePoint.ClubID) == true)
                {
                    dao.Update(homePoint);
                }
                else
                {
                    dao.Insert(homePoint);
                }

                if (dao.CheckExist(visitingPoint.MatchID, visitingPoint.ClubID) == true)
                {
                    dao.Update(visitingPoint);
                }
                else
                {
                    dao.Insert(visitingPoint);
                }
            }

            SetStatusViewBag(matchViewModel.Status);
            return(View(matchViewModel));
        }
Beispiel #33
0
        public IEnumerable <Match> Get()
        {
            var dao = new MatchDao(Context);

            return(dao.GetAll());
        }
Beispiel #34
0
 private void saveMatch()
 {
     //Saving match
     Match match = new Match();
     match.CorrectPoints = GlobalVariables.correctAnswerAmount;
     match.WrongPoints = GlobalVariables.wrongAnswerAmount;
     match.DeckName = GlobalVariables.GetSelectedDeck().DeckName;
     match.MatchNumber = GlobalVariables.GetSelectedDeck().TimesPlayed - 1;
     MatchDao matchDao = new MatchDao();
     StartCoroutine(matchDao.saveMatch(match));
 }
Beispiel #35
0
        public void DeleteDaysByIdError()
        {
            MatchDao MatchDao = new MatchDao(database);

            Assert.AreEqual(MatchDao.DeleteById(1), false);
        }