コード例 #1
0
        /// <summary>
        /// Inserts a new <see cref="ActiveStatusEffect"/> into the database.
        /// </summary>
        /// <param name="item">The <see cref="ActiveStatusEffect"/> to insert.</param>
        /// <returns>The <see cref="ActiveStatusEffectID"/> for the <paramref name="item"/>.</returns>
        ActiveStatusEffectID InsertInDatabase(ActiveStatusEffect item)
        {
            // Convert the time
            var secsLeft = GetSecsLeft(item);

            // Create the row
            var values = new CharacterStatusEffectTable
            {
                CharacterID  = Character.ID,
                ID           = new ActiveStatusEffectID(_dbController.ConnectionPool.AutoIncrementValue),
                Power        = item.Power,
                TimeLeftSecs = (ushort)secsLeft,
                StatusEffect = item.StatusEffect.StatusEffectType
            };

            // Insert the data, and get the ID
            long id;

            _insertQuery.ExecuteWithResult(values, out id);

            Debug.Assert(id <= int.MaxValue);
            Debug.Assert(id >= int.MinValue);

            // Return the ID
            return(new ActiveStatusEffectID((int)id));
        }
コード例 #2
0
        public IEnumerable <ICharacterStatusEffectTable> Execute(CharacterID id)
        {
            var ret = new List <ICharacterStatusEffectTable>(4);

            using (var r = ExecuteReader(id))
            {
                while (r.Read())
                {
                    var item = new CharacterStatusEffectTable();
                    item.ReadValues(r);
                    ret.Add(item);
                }
            }

            return(ret);
        }
コード例 #3
0
        /// <summary>
        /// Updates a <see cref="ActiveStatusEffect"/> in the database.
        /// </summary>
        /// <param name="item">The <see cref="ActiveStatusEffect"/> and <see cref="ActiveStatusEffectID"/> to update.</param>
        void UpdateInDatabase(ASEWithID item)
        {
            // Convert the time
            var secsLeft = GetSecsLeft(item.Value);

            // Create the row
            var values = new CharacterStatusEffectTable
            {
                CharacterID  = Character.ID,
                ID           = item.ID,
                Power        = item.Value.Power,
                TimeLeftSecs = (ushort)secsLeft,
                StatusEffect = item.Value.StatusEffect.StatusEffectType
            };

            // Update the row
            _updateQuery.Execute(values);
        }