Ejemplo n.º 1
0
        public void InsertPlayer(DML.Player playerObject)
        {
            if (String.IsNullOrEmpty(playerObject.Name))
            {
                throw new Exception("Nome do jogador necessário");
            }

            IDispatcherPlayer.InsertPlayer(playerObject);
        }
Ejemplo n.º 2
0
        public void Update(DML.Player oldPlayer)
        {
            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.AppendLine("DECLARE @PASSWORD VARCHAR(30), @NAME VARCHAR(30), @ID INT");
            stringBuilder.AppendLine($"SET @PASSWORD = '******'");
            stringBuilder.AppendLine($"SET @NAME = '{oldPlayer.Name}'");
            stringBuilder.AppendLine($"SET @ID = {oldPlayer.ID}");
            stringBuilder.AppendLine("UPDATE USERS");
            stringBuilder.AppendLine("SET NAME = @NAME,");
            stringBuilder.AppendLine("  PASSWORD = @PASSWORD");
            stringBuilder.AppendLine("WHERE ID @ID");

            IUnitOfWork.Executar(stringBuilder.ToString());
        }
Ejemplo n.º 3
0
        public DML.Player GetPlayerInfo(int playerId)
        {
            var row = IUnitOfWork.Consulta($"SELECT * FROM USERS WITH(NOLOCK) WHERE ID = {playerId}").Tables[0].Rows[0];

            var player = new DML.Player
            {
                ID       = Convert.ToInt32(row["ID"]),
                Name     = row["Name"].ToString(),
                Login    = row["Login"].ToString(),
                Password = null,
                Code     = row["Code"].ToString(),
                Money    = Convert.ToDouble(row["Money"])
            };

            return(player);
        }
Ejemplo n.º 4
0
        public void Update(DML.Player player)
        {
            if (player == null)
            {
                throw new ArgumentNullException("Player is required");
            }

            var oldPlayer = FindPlayerByUserName(player.Login);

            if (oldPlayer == null)
            {
                throw new Exception("Player not found");
            }

            oldPlayer.Name     = player.Name ?? oldPlayer.Name;
            oldPlayer.Password = player.Password ?? oldPlayer.Password;

            IDispatcherPlayer.Update(oldPlayer);
        }
Ejemplo n.º 5
0
 public void InsertPlayer(DML.Player playerObject)
 {
     IUnitOfWork.Executar(IUnitOfWork.MontaInsertPorAttributo(playerObject).ToString());
 }