aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Utilities/Tango.MobileEM.UI/Tango.MobileEM.UI.csproj
blob: a1af9a2a1890c7c7691be41ac3d72ac265e3cd9b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
generated by cgit v1.3.1 (git 2.54.0) at 2026-07-24 21:02:16 +0000
 


ass="n">HasPermission(Permissions.RunPPC))
            {
                LogManager.Log("Application is ready! Navigating to home module...");
                await NavigationManager.NavigateTo(NavigationView.HomeModule);
                IsLoading = false;
            }
            else
            {
                LogManager.Log("Application is ready! The logged in user does not have permission to run the application!", LogCategory.Warning);
                await NavigationManager.NavigateTo(NavigationView.NoPermissionsView);
                IsLoading = false;
            }
        }

        #endregion

        #region Event Handlers

        /// <summary>
        /// Handles the <see cref="IAuthenticationProvider.CurrentUserChanged"/> event.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="user">The user.</param>
        private void AuthenticationProvider_CurrentUserChanged(object sender, User user)
        {
            if (user == null)
            {
                Password = String.Empty;
            }
        }

        #endregion

        #region Private Methods

        /// <summary>
        /// Login to the application using the user name and password.
        /// </summary>
        private async void Login()
        {
            LogManager.Log("Login command pressed.");

            if (Validate())
            {
                IsLoading = true;
                UIHelper.DoEvents();

                var user = await AuthenticationProvider.Login(Email, Password);

                if (user == null)
                {
                    IsLoading = false;
                    await NotificationProvider.ShowWarning("Email or password are incorrect.");
                }
            }
            else
            {
                LogManager.Log("Invalid user credentials.");
            }
        }

        #endregion
    }
}