aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoginViewVM.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoginViewVM.cs')
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoginViewVM.cs50
1 files changed, 50 insertions, 0 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoginViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoginViewVM.cs
new file mode 100644
index 000000000..67c116790
--- /dev/null
+++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoginViewVM.cs
@@ -0,0 +1,50 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using Tango.Core.Commands;
+using Tango.MachineStudio.Common.Authentication;
+using Tango.MachineStudio.Common.Navigation;
+using Tango.SharedUI;
+
+namespace Tango.MachineStudio.UI.ViewModels
+{
+ public class LoginViewVM : ViewModel
+ {
+ private IAuthenticationProvider _authenticationProvider;
+ private INavigationManager _navigationManager;
+
+ private String _email;
+ public String Email
+ {
+ get { return _email; }
+ set { _email = value; RaisePropertyChangedAuto(); }
+ }
+
+ public RelayCommand<PasswordBox> LoginCommand { get; set; }
+
+ public LoginViewVM(IAuthenticationProvider authenticationProvider, INavigationManager navigationManager)
+ {
+ _navigationManager = navigationManager;
+ _authenticationProvider = authenticationProvider;
+ LoginCommand = new RelayCommand<PasswordBox>(Login);
+ }
+
+ private void Login(PasswordBox passwordBox)
+ {
+ String password = passwordBox.Password;
+ try
+ {
+ _authenticationProvider.Login(Email, password);
+ _navigationManager.NavigateTo(NavigationView.MainView);
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show("Failed");
+ }
+ }
+ }
+}