Exemplo n.º 1
0
        public IEnumerable <football_club> ListClub_BySeason(ref string seasonID, int page, int page_size)
        {
            string tmp_seasonID = seasonID;
            var    result       = new season_dao().CheckSeason(seasonID);

            if (result)
            {
                var model = from a in db.football_club
                            join b in db.season_club
                            on a.id equals b.idx_fooballClub_id
                            where b.idx_season_id == tmp_seasonID
                            select a;
                return(model.OrderBy(x => x.id).ToPagedList(page, page_size));
            }
            else
            {
                string current_season = db.seasons.OrderByDescending(x => x.display_order).Select(x => x.id).First().ToString();
                var    model          = from a in db.football_club
                                        join b in db.season_club
                                        on a.id equals b.idx_fooballClub_id
                                        where b.idx_season_id == current_season
                                        select a;
                seasonID = current_season;
                return(model.OrderBy(x => x.id).ToPagedList(page, page_size));
            }
        }
Exemplo n.º 2
0
        public IEnumerable <match> ListMatch_BySeasonRound(ref string seasonID, ref string roundID, int page, int page_size)
        {
            string tmp_seasonID  = seasonID;
            string tmp_roundID   = roundID;
            var    result_season = new season_dao().CheckSeason(seasonID);
            var    result_round  = new round_dao().CheckRound(roundID);

            if (result_round == true && result_season == true)
            {
                var model = db.matches.Where(x => x.season_id == tmp_seasonID && x.round_id == tmp_roundID).ToList();
                return(model.OrderBy(x => x.date_at).ThenBy(x => x.time_at).ToPagedList(page, page_size));
            }
            else
            {
                string current_season = db.seasons.OrderByDescending(x => x.display_order).Select(x => x.id).First().ToString();
                string current_round  = db.rounds.OrderBy(x => x.display_order).Select(x => x.id).First().ToString();

                var model = db.matches.Where(x => x.season_id == current_season && x.round_id == current_round).ToList();

                seasonID = current_season;
                roundID  = current_round;

                return(model.OrderBy(x => x.date_at).ToPagedList(page, page_size));
            }
        }
Exemplo n.º 3
0
        /// <summary>
        ///Lấy các bàn thắng trong từng trận đấu,
        ///Nếu có mùa giải thì lấy tất cả bàn thắng trong mùa giải,
        ///Thay đổi tham biến
        /// </summary>
        /// <param name="matchID"></param>
        /// <param name="seasonID"></param>
        /// <param name="page"></param>
        /// <param name="page_size"></param>
        /// <returns></returns>
        public IEnumerable <match_goal> ListMatchGoal_ByMatchSeason(ref int?matchID, ref string seasonID, int page, int page_size)
        {
            int?   tmp_matchID   = matchID;
            string tmp_season    = seasonID;
            var    result_match  = new match_dao().CheckMatch(matchID);
            var    result_season = new season_dao().CheckSeason(seasonID);

            if (result_match == true)
            {
                var model = db.match_goal.Where(x => x.match_id == tmp_matchID).ToList();
                return(model.OrderByDescending(x => x.match.date_at).ThenByDescending(x => x.match.time_at).ToPagedList(page, page_size));
            }
            else if (result_season == true)
            {
                var model = db.match_goal.Where(x => x.match.season_id == tmp_season).ToList();
                matchID = 0;//Not found
                return(model.OrderByDescending(x => x.match.date_at).ThenByDescending(x => x.match.time_at).ToPagedList(page, page_size));
            }
            else
            {
                string current_season = db.seasons.OrderByDescending(x => x.display_order).Select(x => x.id).First().ToString();
                var    model          = db.match_goal.Where(x => x.match.season_id == current_season).ToList();
                matchID  = 0; // Not found
                seasonID = current_season;
                return(model.OrderByDescending(x => x.match.date_at).ThenByDescending(x => x.match.time_at).ToPagedList(page, page_size));
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Get all footballer by Club -> Season -> All
        /// Tham biến seasonID
        /// </summary>
        /// <param name="seasonID"></param>
        /// <param name="page"></param>
        /// <param name="page_size"></param>
        /// <param name="club_id"></param>
        /// <returns></returns>
        public IEnumerable <footballer> ListAllPaging(ref string seasonID, int page, int page_size, string club_id = null)
        {
            var result_club   = new football_club_dao().CheckFootballClub(club_id);
            var result_season = new season_dao().CheckSeason(seasonID);
            var tmp_seasonID  = seasonID;

            //Duyệt theo thứ tự ưu tiên club -> season
            if (result_club)
            {
                var model = from a in db.footballers
                            where a.footballClub_id == club_id
                            select a;
                seasonID = null;
                return(model.OrderBy(x => x.id).ToPagedList(page, page_size));
            }
            else if (result_season)
            {
                var model = (from fl in db.footballers
                             from m in db.matches
                             from mg in db.match_goal
                             where (mg.match_id == m.id && m.season_id == tmp_seasonID && mg.footballer_id == fl.id)
                             select fl).Distinct();
                return(model.OrderBy(x => x.name).ToPagedList(page, page_size));
            }
            else
            {
                seasonID = null;
                return(db.footballers.OrderBy(x => x.footballClub_id).ToPagedList(page, page_size));
            }
        }
Exemplo n.º 5
0
        /// <summary>
        ///Đếm tổng số bàn thắng của 1 cầu thủ trong 1 mùa giải,
        ///Default season = null -> count all
        /// </summary>
        /// <param name="seasonID"></param>
        /// <param name="footballerID"></param>
        /// <returns></returns>
        public int CountAllGoal_BySeasonID(string seasonID = null, int?footballerID = null)
        {
            var result_season = new season_dao().CheckSeason(seasonID);

            if (result_season)
            {
                return(db.match_goal.Where(x => x.match.season_id == seasonID).Count(x => x.footballer_id == footballerID));
            }
            else
            {
                return(db.match_goal.Count(x => x.footballer_id == footballerID));
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Lấy tất cả vòng đấu có trong mùa giải
        /// </summary>
        /// <returns></returns>
        public List <round> ListRound_BySeason(string seasonID)
        {
            var result = new season_dao().CheckSeason(seasonID);

            if (result)
            {
                var model = from a in db.rounds
                            join b in db.season_round
                            on a.id equals b.idx_round_id
                            where b.idx_season_id == seasonID
                            select a;
                return(model.OrderBy(x => x.display_order).ToList());
            }
            else
            {
                var current_season = db.seasons.OrderByDescending(x => x.display_order).Select(x => x.id).First().ToString();
                var model          = from a in db.rounds
                                     join b in db.season_round
                                     on a.id equals b.idx_round_id
                                     where b.idx_season_id == current_season
                                     select a;
                return(model.OrderBy(x => x.display_order).ToList());
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// Lấy tất CLB tham gia trong mùa giải
        /// </summary>
        /// <param name="seasonID"></param>
        /// <returns></returns>
        public List <football_club> ListClub_BySeason(string seasonID)
        {
            var result = new season_dao().CheckSeason(seasonID);

            if (result)
            {
                var model = from a in db.football_club
                            join b in db.season_club
                            on a.id equals b.idx_fooballClub_id
                            where b.idx_season_id == seasonID
                            select a;
                return(model.OrderBy(x => x.id).ToList());
            }
            else
            {
                var currentSeasonID = db.seasons.OrderByDescending(x => x.display_order).Select(x => x.id).FirstOrDefault().ToString();
                var model           = from a in db.football_club
                                      join b in db.season_club
                                      on a.id equals b.idx_fooballClub_id
                                      where b.idx_season_id == currentSeasonID
                                      select a;
                return(model.OrderBy(x => x.id).ToList());
            }
        }
Exemplo n.º 8
0
        public IEnumerable <rank> ListClubRank_BySeason(ref string seasonID, string sortType1 = "totalScore", string sortType2 = "goalDifference", string sortType3 = "winScore", string sortType4 = "winScoreGuest")
        {
            string             tmp_seasonID = seasonID;
            var                rule         = new general_rule_dao().GetRule();
            var                result       = new season_dao().CheckSeason(seasonID);
            IEnumerable <rank> model        = null;

            if (result)
            {
                model = db.ranks.Where(x => x.season_id == tmp_seasonID);
            }
            else
            {
                string current_season = db.seasons.OrderByDescending(x => x.display_order).Select(x => x.id).First().ToString();
                model    = db.ranks.Where(x => x.season_id == current_season);
                seasonID = current_season;
            }

            // Sắp xếp bảng xếp hạng theo 4 điều lệ truyền vào
            // Theo thứ tứ từ sortType1,2,3,4
            switch (sortType1)
            {
            //Rơi vào thứ tự sắp đầu tiên theo điều kiện
            case "totalScore":
            {
                switch (sortType2)
                {
                //Rơi vào thứ tự sắp đầu tiên + thứ 2 theo điều kiện
                case "goalDifference":
                {
                    //Rơi vào thứ tự sắp đầu tiên + thứ 2 + thứ 3 theo điều kiện
                    switch (sortType3)
                    {
                    //Rơi vào thứ tự sắp đầu tiên + thứ 2 + thứ 3 + thứ 4(là loại cuối) theo điều kiện
                    case "winScore":
                    {
                        model = model.OrderByDescending(x => (x.win_match * rule.win_score) + (x.draw_match * rule.draw_score) + (x.lose_match * rule.lose_score)).ThenByDescending(x => (x.win_score - x.lose_score)).ThenByDescending(x => x.win_score).ThenByDescending(x => x.win_match_guest).ToList();
                        break;
                    }

                    case "winScoreGuest":
                    {
                        model = model.OrderByDescending(x => (x.win_match * rule.win_score) + (x.draw_match * rule.draw_score) + (x.lose_match * rule.lose_score)).ThenByDescending(x => (x.win_score - x.lose_score)).ThenByDescending(x => x.win_match_guest).ThenByDescending(x => x.win_score).ToList();
                        break;
                    }
                    }
                    break;
                }

                //Kết thúc kiểm tra thứ tự ưu tiên thứ 2
                case "winScore":
                {
                    switch (sortType3)
                    {
                    case "goalDifference":
                    {
                        model = model.OrderByDescending(x => (x.win_match * rule.win_score) + (x.draw_match * rule.draw_score) + (x.lose_match * rule.lose_score)).ThenByDescending(x => x.win_score).ThenByDescending(x => (x.win_score - x.lose_score)).ThenByDescending(x => x.win_match_guest).ToList();
                        break;
                    }

                    case "winScoreGuest":
                    {
                        model = model.OrderByDescending(x => (x.win_match * rule.win_score) + (x.draw_match * rule.draw_score) + (x.lose_match * rule.lose_score)).ThenByDescending(x => x.win_score).ThenByDescending(x => x.win_match_guest).ThenByDescending(x => (x.win_score - x.lose_score)).ToList();
                        break;
                    }
                    }
                    break;
                }

                case "winScoreGuest":
                {
                    switch (sortType3)
                    {
                    case "goalDifference":
                    {
                        model = model.OrderByDescending(x => (x.win_match * rule.win_score) + (x.draw_match * rule.draw_score) + (x.lose_match * rule.lose_score)).ThenByDescending(x => x.win_match_guest).ThenByDescending(x => (x.win_score - x.lose_score)).ThenByDescending(x => x.win_score).ToList();
                        break;
                    }

                    case "winScore":
                    {
                        model = model.OrderByDescending(x => (x.win_match * rule.win_score) + (x.draw_match * rule.draw_score) + (x.lose_match * rule.lose_score)).ThenByDescending(x => x.win_match_guest).ThenByDescending(x => x.win_score).ThenByDescending(x => (x.win_score - x.lose_score)).ToList();
                        break;
                    }
                    }
                    break;
                }
                }
                break;
            }

            //Kết thúc kiểm tra thứ tự ưu tiên thứ 1
            case "goalDifference":
            {
                switch (sortType2)
                {
                case "totalScore":
                {
                    switch (sortType3)
                    {
                    case "winScore":
                    {
                        model = model.OrderByDescending(x => (x.win_score - x.lose_score)).ThenByDescending(x => (x.win_match * rule.win_score) + (x.draw_match * rule.draw_score) + (x.lose_match * rule.lose_score)).ThenByDescending(x => x.win_score).ThenByDescending(x => x.win_match_guest).ToList();
                        break;
                    }

                    case "winScoreGuest":
                    {
                        model = model.OrderByDescending(x => (x.win_score - x.lose_score)).ThenByDescending(x => (x.win_match * rule.win_score) + (x.draw_match * rule.draw_score) + (x.lose_match * rule.lose_score)).ThenByDescending(x => x.win_match_guest).ThenByDescending(x => x.win_score).ToList();
                        break;
                    }
                    }
                    break;
                }

                case "winScore":
                {
                    switch (sortType3)
                    {
                    case "totalScore":
                    {
                        model = model.OrderByDescending(x => (x.win_score - x.lose_score)).ThenByDescending(x => x.win_score).ThenByDescending(x => (x.win_match * rule.win_score) + (x.draw_match * rule.draw_score) + (x.lose_match * rule.lose_score)).ThenByDescending(x => x.win_match_guest).ToList();
                        break;
                    }

                    case "winScoreGuest":
                    {
                        model = model.OrderByDescending(x => (x.win_score - x.lose_score)).ThenByDescending(x => x.win_score).ThenByDescending(x => x.win_match_guest).ThenByDescending(x => (x.win_match * rule.win_score) + (x.draw_match * rule.draw_score) + (x.lose_match * rule.lose_score)).ToList();
                        break;
                    }
                    }
                    break;
                }

                case "winScoreGuest":
                {
                    switch (sortType3)
                    {
                    case "totalScore":
                    {
                        model = model.OrderByDescending(x => (x.win_score - x.lose_score)).ThenByDescending(x => (x.win_match * rule.win_score) + (x.draw_match * rule.draw_score) + (x.lose_match * rule.lose_score)).ThenByDescending(x => x.win_match_guest).ThenByDescending(x => x.win_score).ToList();
                        break;
                    }

                    case "winScore":
                    {
                        model = model.OrderByDescending(x => (x.win_score - x.lose_score)).ThenByDescending(x => (x.win_match * rule.win_score) + (x.draw_match * rule.draw_score) + (x.lose_match * rule.lose_score)).ThenByDescending(x => x.win_score).ThenByDescending(x => x.win_match_guest).ToList();
                        break;
                    }
                    }
                    break;
                }
                }
                break;
            }

            case "winScore":
            {
                switch (sortType2)
                {
                case "totalScore":
                {
                    switch (sortType3)
                    {
                    case "goalDifference":
                    {
                        model = model.OrderByDescending(x => x.win_score).ThenByDescending(x => (x.win_match * rule.win_score) + (x.draw_match * rule.draw_score) + (x.lose_match * rule.lose_score)).ThenByDescending(x => (x.win_score - x.lose_score)).ThenByDescending(x => x.win_match_guest).ToList();
                        break;
                    }

                    case "winScoreGuest":
                    {
                        model = model.OrderByDescending(x => x.win_score).ThenByDescending(x => (x.win_match * rule.win_score) + (x.draw_match * rule.draw_score) + (x.lose_match * rule.lose_score)).ThenByDescending(x => x.win_match_guest).ThenByDescending(x => (x.win_score - x.lose_score)).ToList();
                        break;
                    }
                    }
                    break;
                }

                case "goalDifference":
                {
                    switch (sortType3)
                    {
                    case "totalScore":
                    {
                        model = model.OrderByDescending(x => x.win_score).ThenByDescending(x => (x.win_score - x.lose_score)).ThenByDescending(x => (x.win_match * rule.win_score) + (x.draw_match * rule.draw_score) + (x.lose_match * rule.lose_score)).ThenByDescending(x => x.win_match_guest).ToList();
                        break;
                    }

                    case "winScoreGuest":
                    {
                        model = model.OrderByDescending(x => x.win_score).ThenByDescending(x => (x.win_score - x.lose_score)).ThenByDescending(x => x.win_match_guest).ThenByDescending(x => (x.win_match * rule.win_score) + (x.draw_match * rule.draw_score) + (x.lose_match * rule.lose_score)).ToList();
                        break;
                    }
                    }
                    break;
                }

                case "winScoreGuest":
                {
                    switch (sortType3)
                    {
                    case "totalScore":
                    {
                        model = model.OrderByDescending(x => x.win_score).ThenByDescending(x => x.win_match_guest).ThenByDescending(x => (x.win_match * rule.win_score) + (x.draw_match * rule.draw_score) + (x.lose_match * rule.lose_score)).ThenByDescending(x => (x.win_score - x.lose_score)).ToList();
                        break;
                    }

                    case "goalDifference":
                    {
                        model = model.OrderByDescending(x => x.win_score).ThenByDescending(x => x.win_match_guest).ThenByDescending(x => (x.win_score - x.lose_score)).ThenByDescending(x => (x.win_match * rule.win_score) + (x.draw_match * rule.draw_score) + (x.lose_match * rule.lose_score)).ToList();
                        break;
                    }
                    }
                    break;
                }
                }
                break;
            }

            case "winScoreGuest":
            {
                switch (sortType2)
                {
                case "totalScore":
                {
                    switch (sortType3)
                    {
                    case "goalDifference":
                    {
                        model = model.OrderByDescending(x => x.win_match_guest).ThenByDescending(x => (x.win_match * rule.win_score) + (x.draw_match * rule.draw_score) + (x.lose_match * rule.lose_score)).ThenByDescending(x => (x.win_score - x.lose_score)).ThenByDescending(x => x.win_score).ToList();
                        break;
                    }

                    case "winScore":
                    {
                        model = model.OrderByDescending(x => x.win_match_guest).ThenByDescending(x => (x.win_match * rule.win_score) + (x.draw_match * rule.draw_score) + (x.lose_match * rule.lose_score)).ThenByDescending(x => x.win_score).ThenByDescending(x => (x.win_score - x.lose_score)).ToList();
                        break;
                    }
                    }
                    break;
                }

                case "goalDifference":
                {
                    switch (sortType3)
                    {
                    case "totalScore":
                    {
                        model = model.OrderByDescending(x => x.win_match_guest).ThenByDescending(x => (x.win_score - x.lose_score)).ThenByDescending(x => (x.win_match * rule.win_score) + (x.draw_match * rule.draw_score) + (x.lose_match * rule.lose_score)).ThenByDescending(x => x.win_score).ToList();
                        break;
                    }

                    case "winScore":
                    {
                        model = model.OrderByDescending(x => x.win_match_guest).ThenByDescending(x => (x.win_score - x.lose_score)).ThenByDescending(x => x.win_score).ThenByDescending(x => (x.win_match * rule.win_score) + (x.draw_match * rule.draw_score) + (x.lose_match * rule.lose_score)).ToList();
                        break;
                    }
                    }
                    break;
                }

                case "winScore":
                {
                    switch (sortType3)
                    {
                    case "totalScore":
                    {
                        model = model.OrderByDescending(x => x.win_match_guest).ThenByDescending(x => x.win_score).ThenByDescending(x => (x.win_match * rule.win_score) + (x.draw_match * rule.draw_score) + (x.lose_match * rule.lose_score)).ThenByDescending(x => (x.win_score - x.lose_score)).ToList();
                        break;
                    }

                    case "goalDifference":
                    {
                        model = model.OrderByDescending(x => x.win_match_guest).ThenByDescending(x => x.win_score).ThenByDescending(x => (x.win_score - x.lose_score)).ThenByDescending(x => (x.win_match * rule.win_score) + (x.draw_match * rule.draw_score) + (x.lose_match * rule.lose_score)).ToList();
                        break;
                    }
                    }
                    break;
                }
                }
                break;
            }
            }
            return(model.ToList());
        }