Beispiel #1
0
        public static bool AddGeocacheImage(Database db, GeocacheImageData gd)
        {
            bool          result = true;
            GeocacheImage gc     = db.GeocacheImageCollection.GetGeocacheImage(gd.ID);

            if (gc == null)
            {
                gc = new GeocacheImage(db, gd);
            }
            else
            {
                if (gc.DataFromDate < gd.DataFromDate)
                {
                    gc.BeginUpdate();
                    GeocacheImageData.Copy(gd, gc);
                    gc.EndUpdate();
                }
            }
            return(result);
        }
Beispiel #2
0
 public Geocache(Dictionary <string, object> dictionary)
 {
     code     = dictionary["code"] as string;
     name     = dictionary["name"] as string;
     location = dictionary["location"] as string;
     type     = dictionary["type"] as string;
     status   = dictionary["status"] as string;
     url      = dictionary["url"] as string;
     owner    = new User(dictionary["owner"] as Dictionary <string, object>);
     is_found = (bool)dictionary["is_found"];
     size2    = dictionary["size2"] as string;
     if (dictionary["difficulty"].GetType() == typeof(int))
     {
         difficulty = (int)dictionary["difficulty"];
     }
     else
     {
         difficulty = (double)(decimal)dictionary["difficulty"];
     }
     if (dictionary["terrain"].GetType() == typeof(int))
     {
         terrain = (int)dictionary["terrain"];
     }
     else
     {
         terrain = (double)(decimal)dictionary["terrain"];
     }
     description = dictionary["description"] as string;
     hint2       = dictionary["hint2"] as string;
     owner       = new User(dictionary["owner"] as Dictionary <string, object>);
     images      = new List <GeocacheImage>();
     if (dictionary["images"] as object[] != null)
     {
         foreach (Dictionary <string, object> dict in dictionary["images"] as object[])
         {
             GeocacheImage gc = new GeocacheImage(dict);
             images.Add(gc);
         }
     }
     attr_acodes = new List <string>();
     if (dictionary["attr_acodes"] as object[] != null)
     {
         foreach (string s in dictionary["attr_acodes"] as object[])
         {
             attr_acodes.Add(s);
         }
     }
     latest_logs = new List <Log>();
     if (dictionary["latest_logs"] as object[] != null)
     {
         foreach (Dictionary <string, object> dict in dictionary["latest_logs"] as object[])
         {
             Log lg = new Log(dict);
             lg.cache_code = code;
             latest_logs.Add(lg);
         }
     }
     country     = dictionary["country"] as string;
     state       = dictionary["state"] as string;
     date_hidden = dictionary["date_hidden"] as string;
     alt_wpts    = new List <Waypoint>();
     if (dictionary["alt_wpts"] as object[] != null)
     {
         foreach (Dictionary <string, object> dict in dictionary["alt_wpts"] as object[])
         {
             Waypoint lg = new Waypoint(dict);
             lg.cache_code = code;
             alt_wpts.Add(lg);
         }
     }
 }