/// <summary>
        /// Attempts to log the user in
        /// </summary>
        /// <param name="parameter">The SecureString passed in from the view for the users password</param>
        /// <returns></returns>
        public async void Login(PasswordBox parameter)
        {
            CommandHelper ch = new CommandHelper();

            await ch.RunBackgroundWorkerWithFlagHelperAsync(() => IsLoginRunning, async() =>
            {
                try
                {
                    //var pwBox = (PasswordBox)parameter;
                    string username = this.Email ?? "";

                    using (var db = new ApirsDatabase())
                    {
                        var paramLoginName = new SqlParameter
                        {
                            ParameterName = "pLoginName",
                            Value         = username,
                            Direction     = ParameterDirection.Input
                        };

                        var paramPass = new SqlParameter
                        {
                            ParameterName = "pPassword",
                            Value         = parameter.Password,
                            Direction     = ParameterDirection.Input
                        };

                        var paramResponse = new SqlParameter
                        {
                            ParameterName = "responseMessage",
                            Size          = 250,
                            SqlDbType     = SqlDbType.NVarChar,
                            Direction     = ParameterDirection.Output
                        };


                        string par = db.Database.SqlQuery <string>("exec dbo.spUserLogin @pLoginName, @pPassword, @responseMessage", paramLoginName, paramPass, paramResponse).First();

                        //Forward the user to the home view or denying the login based on the response of the server
                        switch (par)
                        {
                        case "Invalid login":
                        case "Incorrect password":
                            _events.PublishOnUIThreadAsync(new MessageBoxMessage("Wrong password. Please try it again", "", MessageBoxViewType.Information, MessageBoxViewButton.Ok));
                            break;

                        case "User successfully logged in":
                            //Get the actual user id and set it as a property in the shellview
                            tblPerson result = (from p in db.tblPersons
                                                where p.persUserName == username.ToString()
                                                select p).First();
                            _events.PublishOnUIThreadAsync(new ChangeUserMessage(Convert.ToInt32(result.persIdPk), result.persFullName));
                            //Changing the viewmodel to the homeview
                            _events.PublishOnUIThreadAsync(new ChangeViewModelMessage("HomeView"));
                            break;

                        default:
                            break;
                        }
                    }

                    return;
                }
                catch (Exception e)
                {
                    _events.PublishOnUIThreadAsync(new MessageBoxMessage(UserMessageValueConverter.ConvertBack(1), "", MessageBoxViewType.Error, MessageBoxViewButton.Ok));
                }
            });
        }