Exemplo n.º 1
0
        public static UserDB ConvertFromUser(User item)
        {
            UserDB toReturn = new UserDB ();
            toReturn.AccountActive = item.AccountActive;
            toReturn.AccountID = item.AccountID;
            toReturn.DateOfBirth = item.DateOfBirth;
            toReturn.EmailAddress = item.EmailAddress;
            toReturn.Errors = item.Errors;
            toReturn.FirstName = item.FirstName;
            toReturn.LastName = item.LastName;
            toReturn.Password = item.Password;
            toReturn.Picture = item.Picture;
            toReturn.PictureURL = item.PictureURL;
            toReturn.HasProfileImage = item.HasProfileImage;
            toReturn.AllowLocationSearch = item.AllowLocationSearch;
            toReturn.AllowSearch = item.AllowSearch;
            toReturn.DateCreated = item.DateCreated;
            toReturn.Description = item.Description;
            toReturn.Latitude = item.Latitude;
            toReturn.Longitude = item.Longitude;
            toReturn.ShowLocation = item.ShowLocation;
            toReturn.UserGender = item.UserGender;
            toReturn.UserName = item.UserName;

            return toReturn;
        }
        /// <summary>
        /// Disconnect an user from the server
        /// </summary>
        /// <param name="user"></param>
        /// <returns></returns>
        public bool Disconnect(User user)
        {
            foreach (var token in _tokensByUser[user.Id])
            {
                _tokens.Remove(token);
            }
            _authenticatedUsers.Remove(user);

            return _tokensByUser.Remove(user.Id);
        }
Exemplo n.º 3
0
        public void InsertOrUpdateUser(User user)
        {
            lock (this.dbLock)
            {

                using (SQLiteConnection sqlCon = new SQLiteConnection(this.DBPath))
                {

                    sqlCon.Execute(WZConstants.DBClauseSyncOff);

                    sqlCon.BeginTransaction();

                    try
                    {

                        UserDB userDB = UserDB.ConvertFromUser(user);
                        if (sqlCon.Execute("UPDATE UserDB SET " +
                            "AccountActive=?, " +
                            "AccountGuid=?, " +
                            "DateOfBirth=?, " +
                            "EmailAddress=?, " +
                            "FirstName=?, " +
                            "LastName=?, " +
                            "Password=?, " +
                            "Picture=?, " +
                            "PictureUrl=?, " +
                            "HasProfileImage=? " +
                            "WHERE AccountGuid=?",
                                               userDB.AccountActive,
                                               userDB.AccountGuid,
                                               userDB.DateOfBirth,
                                               userDB.EmailAddress,
                                               userDB.FirstName,
                                               userDB.LastName,
                                               userDB.Password,
                                               userDB.Picture,
                                               userDB.PictureURL,
                                               userDB.HasProfileImage,
                                               userDB.AccountGuid) == 0)
                        {

                            sqlCon.Insert(userDB, typeof(UserDB));
                        }//end if

                        sqlCon.Commit();

                    } catch (Exception ex)
                    {

            #if(DEBUG)
                        Console.WriteLine("Error in InsertOrUpdateContact! {0}--{1}", ex.Message, ex.StackTrace);
            #endif
                        sqlCon.Rollback();

                    }//end try catch

                }//end using sqlCon

            }//end lock
        }
Exemplo n.º 4
0
 public void LoadUser()
 {
     this.Connection.CreateTable<User>();
     var testUser = new User() { Id = 1, Username = "******", Guid = Guid.NewGuid().ToString(), Password = "******" };
     this.Connection.Insert(testUser);
 }