blob: 77b15adc43e98c4d562f0ede94fad875e69f214f (
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
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tango.Core.Commands;
using Tango.FSE.Common;
using Tango.FSE.Common.Navigation;
using Tango.MachineService.Gateway;
namespace Tango.FSE.UI.ViewModels
{
public class LoginViewVM : FSEViewModel
{
private String _email;
public String Email
{
get { return _email; }
set { _email = value; RaisePropertyChangedAuto(); InvalidateRelayCommands(); }
}
private String _password;
public String Password
{
get { return _password; }
set { _password = value; RaisePropertyChangedAuto(); InvalidateRelayCommands(); }
}
private EnvironmentConfiguration _selectedEnvironment;
public EnvironmentConfiguration SelectedEnvironment
{
get { return _selectedEnvironment; }
set { _selectedEnvironment = value; RaisePropertyChangedAuto(); InvalidateRelayCommands(); }
}
public RelayCommand LoginCommand { get; set; }
public LoginViewVM()
{
LoginCommand = new RelayCommand(Login,() => Email.IsNotNullOrEmpty() && Password.IsNotNullOrEmpty() && SelectedEnvironment != null);
}
public override void OnApplicationStarted()
{
Email = "roy@twine-s.com";
Password = "1Creativity";
}
public override void OnNavigatedTo()
{
base.OnNavigatedTo();
SelectedEnvironment = GatewayService.Environments.FirstOrDefault();
}
private async void Login()
{
try
{
var result = await AuthenticationProvider.Login(Email, Password, SelectedEnvironment);
if (!result.Response.PasswordChangeRequired)
{
await NavigationManager.NavigateTo(NavigationView.Home);
}
}
catch (Exception ex)
{
await NotificationProvider.ShowError(ex.Message);
}
}
}
}
|