Exemplo n.º 1
0
        /// <summary>
        ///  This command has been executed when the login is
        /// </summary>
        /// <param name="viewObject">UserViewObject to be visualized.</param>
        private void OnLogin(object viewObject)
        {
            var currentData = DataObject;
            var user        = new User
            {
                Name   = currentData.USUARIO,
                Office = new Office {
                    Code = currentData.OFI_COD
                },
                Password = currentData.PASS
            };

            NotifyTaskCompletion.Create <bool>(authService.CanAccess(user, this.configurationService),
                                               (task, ev) =>
            {
                if (task is INotifyTaskCompletion <bool> taskCompletion)
                {
                    if (taskCompletion.IsSuccessfullyCompleted)
                    {
                        if (taskCompletion.Result)
                        {
                            IsLogged = true;
                            View?.Close();
                        }
                        else
                        {
                            IsLogged   = false;
                            LoginError = KarveLocale.Properties.Resources.linvalidpass;
                        }
                    }
                }
            });
        }