Exemple #1
0
        private void ExecuteLoginCommand(Object args)
        {
            //Use Authentication service to check login
            var loginSuccess = authenticateService.Authenticate(UserName.DataValue.ToLower(), Password.DataValue, SelectedBusinessUnit.DataValue);

            if (loginSuccess)
            {
                if (viewInjectionService.ClearRegionOfAllViews("RootRegion"))
                {
                    if (!viewInjectionService.AddViewToRegion("RootRegion", "MainView", new MainView()))
                    {
                        messageBoxService.ShowError(viewInjectionService.Error);
                    }
                }
                else
                {
                    messageBoxService.ShowError(viewInjectionService.Error);
                }

                #region This method Injects view but it caches it

                /*
                 * var export = ViewModelRepository.Instance.Resolver.Container.GetExport<MainView>();
                 *
                 * if (export != null)
                 * {
                 *  object mainView = export.Value;
                 *  //object mainView = export;
                 *  if (viewInjectionService.ClearRegionOfAllViews("RootRegion"))
                 *  {
                 *      if (!viewInjectionService.AddViewToRegion("RootRegion", "MainView", mainView))
                 *      {
                 *          messageBoxService.ShowError(viewInjectionService.Error);
                 *      }
                 *  }
                 *  else
                 *  {
                 *      messageBoxService.ShowError(viewInjectionService.Error);
                 *  }
                 * }
                 * else
                 * {
                 *  messageBoxService.ShowError("Create view MainView");
                 * }*/
            }
            else
            {
                messageBoxService.ShowError("Incorrect username/password combintation");
            }
            #endregion
        }
        public void Initialize()
        {
            if (viewInjectionService.ClearRegionOfAllViews("RootRegion"))
            {
                //Disable Authentication
                if (!viewInjectionService.AddViewToRegion("RootRegion", "MainView", new MainView()))
                {
                    messageBoxService.ShowError(viewInjectionService.Error);
                }
                //Enable Authentication

                /* if (!viewInjectionService.AddViewToRegion("RootRegion", "LoginView", new LoginView()))
                 * {
                 *   messageBoxService.ShowError(viewInjectionService.Error);
                 * }*/
            }
            else
            {
                messageBoxService.ShowError(viewInjectionService.Error);
            }
        }
Exemple #3
0
        private void ExecuteLogoutCommand(Object args)
        {
            if (viewInjectionService.ClearRegionOfAllViews("RootRegion"))
            {
                if (!viewInjectionService.AddViewToRegion("RootRegion", "LoginView", new LoginView()))
                {
                    messageBoxService.ShowError(viewInjectionService.Error);
                }
            }
            else
            {
                messageBoxService.ShowError(viewInjectionService.Error);
            }
            #region This injects view but it also caches it

            /*var export = ViewModelRepository.Instance.Resolver.Container.GetExport<LoginView>();
             * //ViewModelRepository.Instance.Resolver.Container.
             * //var export = new LoginView();
             * if (export != null)
             * {
             *  object loginView = export.Value;
             *  //  object loginView = export;
             *  if (viewInjectionService.ClearRegionOfAllViews("RootRegion"))
             *  {
             *      if (!viewInjectionService.AddViewToRegion("RootRegion", "LoginView", loginView))
             *      {
             *          messageBoxService.ShowError(viewInjectionService.Error);
             *      }
             *  }
             *  else
             *  {
             *      messageBoxService.ShowError(viewInjectionService.Error);
             *  }
             * }
             * else
             * {
             *  messageBoxService.ShowError("Create view LoginView");
             * }*/
            #endregion
        }
 private void ExecuteAddNewUserCommand(Object args)
 {
     //Inject Add User view
     viewInjectionService.ClearRegionOfAllViews("MainContentRegion");
     viewInjectionService.AddViewToRegion("MainContentRegion", "AddNewUserView", new AddNewUserView());
 }