コード例 #1
0
 public JsonResult AddRow(string row)
 {
     try
     {
         var        json       = new JavaScriptSerializer().Deserialize <ClubPlayer>(row);
         ClubPlayer clubPlayer = new ClubPlayer();
         clubPlayer.ClubID   = json.ClubID;
         clubPlayer.PlayerID = json.PlayerID;
         clubPlayer.Status   = true;
         var dao = new ClubPlayerDao();
         if (dao.CheckExistRow(clubPlayer.ClubID, clubPlayer.PlayerID) == false)
         {
             dao.Insert(clubPlayer);
             return(Json(new
             {
                 status = true
             }));
         }
         else
         {
             return(Json(new
             {
                 status = false
             }));
         }
     }
     catch (Exception ex)
     {
         return(Json(new
         {
             status = false
         }));
     }
 }
コード例 #2
0
        public JsonResult AddPlayer(string clubPlayerViewModel)
        {
            var json = new JavaScriptSerializer().Deserialize <ClubPlayerViewModel>(clubPlayerViewModel);

            //Insert thêm một Player mới vào bảng Player
            Player player = new Player()
            {
                Name = json.PlayerName, Identification = json.PlayerIdentification, Address = json.PlayerAddress, Email = json.PlayerEmail, Phone = json.PlayerPhone, Image = json.PlayerImage
            };
            long playerId = new PlayerDao().Insert(player);

            //Insert thêm một dòng vào bảng ClubPlayer
            ClubPlayer clubPlayer = new ClubPlayer()
            {
                ClubID = json.ClubID, PlayerID = playerId, Status = true
            };
            var dao = new ClubPlayerDao();

            if (dao.CheckExistRow(clubPlayer.ClubID, clubPlayer.PlayerID) == false)
            {
                dao.Insert(clubPlayer);
                return(Json(new
                {
                    status = true
                }));
            }
            else
            {
                return(Json(new
                {
                    status = false
                }));
            }
        }
コード例 #3
0
        public ActionResult Edit(long id)
        {
            var club       = new ClubDao().GetByID(id);
            var listPlayer = new ClubPlayerDao().ListClubPlayer(id);

            ViewBag.ListPlayer = listPlayer;
            return(View(club));
        }
コード例 #4
0
        //Delete an ClubPlayer
        public JsonResult Delete(long clubId, int stt)
        {
            var dao    = new ClubPlayerDao();
            var resDel = dao.Delete(clubId, stt);

            if (resDel)
            {
                return(Json(new
                {
                    status = true
                }));
            }
            else
            {
                return(Json(new
                {
                    status = false
                }));
            }
        }
コード例 #5
0
        //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));
        }
コード例 #6
0
        // GET: ClubPlayer
        public ActionResult Index(long clubId, int pageIndex = 1, int pageSize = 10)
        {
            int totalRecord = 0;
            var model       = new ClubPlayerDao().ListClubPlayerPageList(clubId, ref totalRecord, pageIndex, pageSize);

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

            var club = new ClubDao().GetByID(clubId);

            ViewBag.OwnerID  = club.OwnerID;
            ViewBag.ClubID   = club.ID;
            ViewBag.ClubCode = club.Code;
            ViewBag.ClubName = club.Name;

            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));
        }