示例#1
0
        /// <summary>
        /// Agregar una nueva cuenta del usuario
        /// </summary>
        /// <param name="userCount">Objeto de tipo UserCount con todos los valores a agregar a la tabla usercount</param>
        /// <returns>true si se ha agregado el nuevo registro</returns>
        public bool AddUserCount(UserCount userCount)
        {
            NpgsqlParameter paramEmail    = new NpgsqlParameter(":email", userCount.email);
            NpgsqlParameter paramPassword = new NpgsqlParameter(":pass", userCount.password);
            NpgsqlParameter paramStatus   = new NpgsqlParameter(":status", userCount.status);

            List <NpgsqlParameter> lstParameters = new List <NpgsqlParameter>
            {
                paramEmail, paramPassword, paramStatus
            };

            const string SQL = "INSERT INTO UserCount (email, pass, status) " +
                               "VALUES (:email, :pass, :status)";

            int affected = ExecuteQuery(SQL, lstParameters);

            return(affected > 0);
        }
示例#2
0
        /// <summary>
        /// Actualza una cuenta del usuario
        /// </summary>
        /// <param name="userCount">Objeto de tipo UserCount con todos los valores a agregar a la tabla usercoumt</param>
        /// <returns></returns>
        public bool UpdateUserCount(UserCount userCount)
        {
            NpgsqlParameter paramEmail    = new NpgsqlParameter(":email", userCount.email);
            NpgsqlParameter paramPassword = new NpgsqlParameter(":pass", userCount.password);
            NpgsqlParameter paramStatus   = new NpgsqlParameter(":status", userCount.status);

            List <NpgsqlParameter> lstParameters = new List <NpgsqlParameter>
            {
                paramEmail, paramPassword, paramStatus
            };

            string sql = "UPDATE UserCount SET email = :email, pass = :pass, status = :status " +
                         "WHERE id_usercount = " + userCount.idUserCount;

            int affected = ExecuteQuery(sql, lstParameters);

            return(affected > 0);
        }