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

UpdateRole() public method

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

                if (affected > 0)
                {
                    this.Role = role;

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

            return false;
        }