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