diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-08-13 16:12:45 +0300 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-08-13 16:12:45 +0300 |
| commit | 998cc8d4d91a7f85389cd0918f127257576c2c13 (patch) | |
| tree | 368ecd76f09b8ff1c4156a554b799cd231c42119 /Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LoginViewVM.cs | |
| parent | 4490b0a76d4188cb285d62b106e208803ceaa133 (diff) | |
| download | Tango-998cc8d4d91a7f85389cd0918f127257576c2c13.tar.gz Tango-998cc8d4d91a7f85389cd0918f127257576c2c13.zip | |
Logs and comments for PPC.UI !
Diffstat (limited to 'Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LoginViewVM.cs')
| -rw-r--r-- | Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LoginViewVM.cs | 54 |
1 files changed, 53 insertions, 1 deletions
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LoginViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LoginViewVM.cs index 022efd9b8..812f10121 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LoginViewVM.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LoginViewVM.cs @@ -9,14 +9,25 @@ using Tango.PPC.Common.Navigation; using SimpleValidator.Extensions; using System.ComponentModel.DataAnnotations; using Tango.SharedUI.Helpers; +using Tango.PPC.Common.Authentication; +using Tango.BL.Entities; namespace Tango.PPC.UI.ViewModels { + /// <summary> + /// Represents the PPC login view ViewModel. + /// </summary> + /// <seealso cref="Tango.PPC.Common.PPCViewModel" /> public class LoginViewVM : PPCViewModel { public RelayCommand LoginCommand { get; set; } + #region Properties + private String _email; + /// <summary> + /// Gets or sets the email. + /// </summary> [Required(ErrorMessage = "Email is required")] [EmailAddress(ErrorMessage = "Please enter a valid email address")] public String Email @@ -26,6 +37,9 @@ namespace Tango.PPC.UI.ViewModels } private String _password; + /// <summary> + /// Gets or sets the password. + /// </summary> [Required(ErrorMessage = "Password is required")] public String Password { @@ -43,7 +57,13 @@ namespace Tango.PPC.UI.ViewModels set { _isLoading = value; RaisePropertyChangedAuto(); } } + #endregion + + #region Constructors + /// <summary> + /// Initializes a new instance of the <see cref="LoginViewVM"/> class. + /// </summary> public LoginViewVM() { LoginCommand = new RelayCommand(Login); @@ -52,12 +72,28 @@ namespace Tango.PPC.UI.ViewModels Password = "1234"; } + #endregion + + #region Override Methods + + /// <summary> + /// Called when the application has been started. + /// </summary> public override void OnApplicationStarted() { AuthenticationProvider.CurrentUserChanged += AuthenticationProvider_CurrentUserChanged; } - private void AuthenticationProvider_CurrentUserChanged(object sender, BL.Entities.User user) + #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) { @@ -65,8 +101,17 @@ namespace Tango.PPC.UI.ViewModels } } + #endregion + + #region Private Methods + + /// <summary> + /// Login to the application using the user name and password. + /// </summary> private void Login() { + LogManager.Log("Login command pressed."); + if (Validate()) { IsLoading = true; @@ -83,10 +128,17 @@ namespace Tango.PPC.UI.ViewModels ApplicationManager.ModulesInitialized += async (_, __) => { await Task.Delay(500); + LogManager.Log("Modules initialized. Navigating to home module..."); await NavigationManager.NavigateTo(NavigationView.HomeModule); IsLoading = false; }; } + else + { + LogManager.Log("Invalid user credentials."); + } } + + #endregion } } |
