コード例 #1
0
        public int AddUpdatePlayerSkill(PlayerSkillsDomainModel dm)
        {
            int result = 0;

            if (dm.id > 0) // Edit Player
            {
                PlayerSkills playerSkill = playerSkillRepository.SingleOrDefault(x => x.id == dm.id);

                if (playerSkill != null)
                {
                    playerSkill.atk  = dm.atk;
                    playerSkill.def  = dm.def;
                    playerSkill.pass = dm.pass;
                    playerSkill.spd  = dm.spd;

                    var obj = playerSkillRepository.Insert(playerSkill);

                    result = obj.id;
                }
            }
            else // Add Player
            {
                PlayerSkills playerSkill = new PlayerSkills();

                playerSkill.atk  = dm.atk;
                playerSkill.def  = dm.def;
                playerSkill.pass = dm.pass;
                playerSkill.spd  = dm.spd;

                var obj = playerSkillRepository.Insert(playerSkill);

                result = obj.id;
            }

            return(result);
        }
コード例 #2
0
        public string DeletePlayer(int pId)
        {
            string result = "Failed";

            //if (dm.playerId > 0)
            {
                Players player = playerRepository.SingleOrDefault(x => x.playerId == pId);

                if (player != null)
                {
                    var playerSkill = playerSkillRepository.SingleOrDefault(x => x.id == player.skill);
                    int skillId     = playerSkill.id;
                    playerRepository.Delete(x => x.playerId == pId);
                    playerSkillRepository.Delete(x => x.id == skillId);

                    result = "Deleted";
                }
            }

            return(result);
        }