コード例 #1
0
        public bool DeleteUserPreference(UserPreference preference)
        {
            if (preference == null)
            {
                throw new ArgumentNullException("preference cannot be null.");
            }

            int nRows = _db.Delete <UserPreference>(preference._id);

            return(nRows == 1);
        }
コード例 #2
0
        public bool InsertUserPreference(UserPreference preference)
        {
            if (preference == null)
            {
                throw new ArgumentNullException("preference cannot be null.");
            }

            int nRows = _db.Insert(preference);

            return(nRows == 1);
        }
コード例 #3
0
        /***
         * Creates a UserPreference object for a category and then inserts into the database.
         * Returns true if the UserPreference was successfully added into the storage and false otherwise.
         */
        public bool AddCategory(string category)
        {
            if (string.IsNullOrEmpty(category))
            {
                throw new ArgumentNullException("category cannot be null.");
            }

            UserPreference preference = new UserPreference(category);

            CachedPreferences.Add(category, preference);
            return(Storage.InsertUserPreference(preference));
        }
コード例 #4
0
        public override bool Equals(object obj)
        {
            UserPreference pref = obj as UserPreference;

            if (pref == null)
            {
                return(false);
            }

            return((_category == pref._category) &&
                   (_maxPrice == pref._maxPrice) &&
                   (_minPrice == pref._minPrice));
        }
コード例 #5
0
        public bool UpdateUserPreference(UserPreference preference)
        {
            if (preference == null)
            {
                throw new ArgumentNullException("preference cannot be null.");
            }

            Console.WriteLine("[UpdateUserPreference] preference.id = " + preference._id);

            int nRows = _db.Update(preference);

            return(nRows == 1);
        }
コード例 #6
0
 /***
  * Retrieves a UserPreference object from the cache that corresponds to the filter.
  * i.e filter == preference._category
  *
  * Parameters:
  * [out] preference : UserPreference
  * Returns true if a user preference object was found and false otherwise.
  */
 public bool FindUserPreferenceFromCache(string filter, out UserPreference preference)
 {
     return(CachedPreferences.TryGetValue(filter, out preference));
 }