예제 #1
0
 /// <summary>
 /// Update the user
 /// </summary>
 /// <param name="user">GPSUser object</param>
 public void UpdateUser(GpsUser user)
 {
     // serialize the user
     BsonDocument doc = user.ToBsonDocument();
     // Add extra data (in case we have)
     Utilities.AddExtraData(doc, user);
     // save user
     DB.GetCollection<BsonDocument>(_userColection).Save<BsonDocument>(doc);
 }
예제 #2
0
        //public IList<GPSUser> GetUsers()
        //{
        //    RegisterGpsUserClass();
        //    List<GPSUser> ret = new List<GPSUser>();
        //    MongoCollection collection = DB.GetCollection<BsonDocument>(_userColection);
        //    foreach (BsonDocument usr in collection.FindAllAs<BsonDocument>())
        //    {
        //        ret.Add(GetUserFromDoc(usr, true));
        //    }
        //    return ret;
        //}
        /// <summary>
        /// Register/insert a new user into database
        /// </summary>
        /// <param name="user">User object</param>
        /// <returns>User object</returns>
        public GpsUser InsertUser(GpsUser user)
        {
            // serialize the user
            BsonDocument doc = user.ToBsonDocument();
            // Add extra data (in case we have)
            Utilities.AddExtraData(doc, user);
            // add into user colection inside database
            DB.GetCollection<BsonDocument>(_userColection).Insert<BsonDocument>(doc);

            return user;
        }