TGIMBA Windows Presentation Foundation (WPF) Client – Login and Registration Functionality Added

Git  Code

Welcome back to the The Globe In My BucketList Application (TGIMBA) Windows Presentation Foundation (WPF) client creation. If you remember last time, I had added User Interface (UI) place holders with some minimum button click functionality.

In this post, I will start by adding real functionality. Normally, I would abstract the connection with the back-end system via a Web Web Application Programmatic Interface (API). If this client gets used, I will. In the interim though, I will use the same code API  code that the .NET 4.6 Model View Controller (MVC) website uses for connectivity (from the server).

One thing to note before I start. Given that this is a quick client for exploration, I am not writing tests like I am for the Angular 2 .NET Core 2 TGIMBA Site. If it gets used, I will. I am on an extended Minimum Viable Product (MVP) spike 🙂

First on the implementation list will be logging in. To implement, I updated the Login View Model with the method Login() that calls the Common Service Code ProcessUser() method. If the login is successful, the user will be directed to the Bucket List View. If not, they will be prompted to try again. If they do not enter something, they will be prompted to. I also clear the fields after each use and started using the PasswordBox control so the password typed in is not visible.

  • Login View Model

loginmodel

  • Login View

loginviewcontrol

On thing I was not quite sure how to handle was the stat since it seems like the Model View View Model (MVVM) strategy preaches that a view and its model should be relatively isolated. It also seems from the articles I have read that having a base view model is not a good idea (I am not exactly sure why…having a central base class is usually my first choice). However, the token passed back during login is required for additional calls. Until I figure out a better solution, I am going to create a base view model to store only the essential items like the token. The main window will not have access to it and only each view’s code behind will when it makes a call through its view model.

I updated the Menu View Model with a logout method that clears the token in the Base View Model. This method is called by the Menu View’s code behind when the user clicks logout prior to being directed back to the Login View.

Next, I added the user registration functionality. I added the method Register() to the Register View Model that calls the Common Service Code ProcessRegistration(). If successful, the user is directed back to the login screen. They can cancel the registration to return to the login screen as well. If it is not successful, they are prompted to try again.  I do perform validation on the registration items, but I will have to work in getting these validation errors messages back out to the user.

  • Registration View Model

registrationmodel

  • Registration View

registrationviewcontrol

So, putting it all in action:

  • Application launches and Login View is shown

six

  • User clicks ‘Registration’ and fills out the Registration form

two

  • User clicks ‘Register’ and is directed back to the Login screen. User enters user name and password just created and clicks ‘Login’

three

  • User is directed to the Bucket List View

four

  • User clicks ‘Menu’ and then clicks ‘Logout’

five

  • User is directed to the Login View

six

Here is the user created from the login in the production database:

user

I will add the Bucket List View code tomorrow.

Stay tuned!

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s