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); }
public bool InsertUserPreference(UserPreference preference) { if (preference == null) { throw new ArgumentNullException("preference cannot be null."); } int nRows = _db.Insert(preference); return(nRows == 1); }
/*** * 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)); }
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)); }
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); }
/*** * 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)); }