Esempio n. 1
0
 /// <summary>
 /// Delete an estate object.
 /// </summary>
 /// <param name="key">Key of object to delete.</param>
 /// <returns>True if object was successfully deleted.</returns>
 public static bool DeleteObject(int key)
 {
     if (DealCache.ContainsKey(key))
     {
         return false;
     }
     OrderCache.Query (new SqlFieldsQuery
         ($"delete from Orders where ObjectID={key};"));
     BookmarkCache.Query (new SqlFieldsQuery
         ($"delete from Bookmarks where ObjectID={key};"));
     MatchCache.Query (new SqlFieldsQuery
         ($"delete from Matches where ObjectID={key};"));
     ObjectCache.Remove(key);
     return true;
 }
Esempio n. 2
0
        /// <summary>
        /// Get bookmarked objects.
        /// </summary>
        /// <param name="personid"></param>
        /// <returns>Key-value pairs of bookmarked objects' short descriptions.</returns>
        public static Dictionary <int, string> GetBookmarks(int personid)
        {
            List <int> idlist = new List <int>();
            Dictionary <int, string> result = new Dictionary <int, string>();

            foreach (var row in BookmarkCache.Query(new SqlFieldsQuery($"select ObjectID from Bookmarks where PersonID={personid}")))
            {
                idlist.Add((int)row[0]);
            }
            foreach (var entry in ObjectCache.GetAll(idlist))
            {
                var obj = entry.Value;
                if (obj.Description.Length > 200)
                {
                    obj.Description = obj.Description.Substring(0, 180);
                }
                result.Add(entry.Key, $"{obj.PostDate.ToLocalTime()} | {obj.Price} USD | {obj.Description}");
            }
            return(result);
        }