WaveBox.Core.Model.User.UpdateUsername C# (CSharp) Method

UpdateUsername() public method

public UpdateUsername ( string username ) : bool
username string
return bool
        public bool UpdateUsername(string username)
        {
            ISQLiteConnection conn = null;
            try
            {
                conn = Injection.Kernel.Get<IDatabase>().GetSqliteConnection();
                int affected = conn.Execute("UPDATE User SET UserName = ? WHERE UserId = ?", username, this.UserId);

                if (affected > 0)
                {
                    this.UserName = username;

                    return Injection.Kernel.Get<IUserRepository>().UpdateUserCache(this);
                }
            }
            catch (Exception e)
            {
                logger.Error(e);
            }
            finally
            {
                Injection.Kernel.Get<IDatabase>().CloseSqliteConnection(conn);
            }

            return false;
        }