Exemple #1
0
        public void TestGetCommandOther()
        {
            var messageToShow = "Error Message";

            var messageShown       = "";
            var dialogShown        = false;
            var stubIDialogService = new StubIDialogService();

            stubIDialogService.ShowAsync(async message => {
                dialogShown  = true;
                messageShown = message;
            });

            var getMeRequested      = false;
            var stubIStudentService = new StubIStudentService();

            stubIStudentService.GetMeAsync(async() => {
                getMeRequested = true;
                return(new ServiceResult <Student> {
                    Status = ServiceResultStatus.Exception,
                    Message = messageToShow
                });
            });

            var meViewModel =
                new MeViewModel(stubIStudentService, stubIDialogService);

            meViewModel.GetCommand.Execute(null);

            Assert.IsTrue(dialogShown);
            Assert.AreEqual(
                UvpClient.App.HttpClientErrorMessage + messageToShow,
                messageShown);
            Assert.IsTrue(getMeRequested);
        }
Exemple #2
0
        public async Task <IActionResult> Me()
        {
            var username = User.Claims
                           .FirstOrDefault(x => x.Type == "preferred_username")
                           ?.Value.ToString();

            var viewModel = new MeViewModel
            {
                Username     = username,
                SdkAvailable = _oktaClient != null
            };

            if (!viewModel.SdkAvailable)
            {
                return(View(viewModel));
            }

            if (!string.IsNullOrEmpty(username))
            {
                var user = await _oktaClient.Users.GetUserAsync(username);

                dynamic userInfoWrapper = new ExpandoObject();
                userInfoWrapper.Profile         = user.Profile;
                userInfoWrapper.PasswordChanged = user.PasswordChanged;
                userInfoWrapper.LastLogin       = user.LastLogin;
                userInfoWrapper.Status          = user.Status.ToString();
                viewModel.UserInfo = userInfoWrapper;

                viewModel.Groups = (await user.Groups.ToList()).Select(g => g.Profile.Name).ToArray();

                viewModel.Applications = await user.AppLinks.ToList();
            }

            return(View(viewModel));
        }
Exemple #3
0
        public void TestGetCommandUnauthorized()
        {
            var dialogShown        = false;
            var stubIDialogService = new StubIDialogService();

            stubIDialogService.ShowAsync(async message => dialogShown = true);

            var getMeRequested      = false;
            var stubIStudentService = new StubIStudentService();

            stubIStudentService.GetMeAsync(async() => {
                getMeRequested = true;
                return(new ServiceResult <Student>
                {
                    Status = ServiceResultStatus.Unauthorized
                });
            });

            var meViewModel =
                new MeViewModel(stubIStudentService, stubIDialogService);

            meViewModel.GetCommand.Execute(null);

            Assert.IsFalse(dialogShown);
            Assert.IsTrue(getMeRequested);
        }
Exemple #4
0
        public void TestGetCommandUnauthorized()
        {
            var rootFrameNavigated         = false;
            var stubIRootNavigationService = new StubIRootNavigationService();

            stubIRootNavigationService.Navigate(
                (sourcePageType, parameter, navigationTransition) =>
                rootFrameNavigated = true);

            var dialogShown        = false;
            var stubIDialogService = new StubIDialogService();

            stubIDialogService.ShowAsync(async message => dialogShown = true);

            var checkRequested      = false;
            var stubIStudentService = new StubIStudentService();

            stubIStudentService.GetMeAsync(async() => {
                checkRequested = true;
                return(new ServiceResult <Student>
                {
                    Status = ServiceResultStatus.Unauthorized
                });
            });

            var meViewModel =
                new MeViewModel(stubIStudentService, stubIDialogService);

            meViewModel.GetCommand.Execute(null);

            Assert.IsFalse(rootFrameNavigated);
            Assert.IsFalse(dialogShown);
            Assert.IsTrue(checkRequested);
        }
Exemple #5
0
        /// <summary>
        /// 个人信息展示页面
        /// </summary>
        /// <returns></returns>
        public ActionResult Me(int?id)
        {
            return(RunAction(() =>
            {
                id = id ?? (this.X.LoginUser?.IID ?? 0);

                if (id <= 0)
                {
                    return GoHome();
                }

                var user = _IUserService.GetByID(id.Value);
                if (user == null)
                {
                    return GoHome();
                }

                var model = new MeViewModel();
                model.User = user;
                model.IsMe = model.User.UserID == (this.X.LoginUser?.IID ?? 0);

                ViewData["model"] = model;

                return View();
            }));
        }
        public AboutDialog()
        {
            // Load the viewModel
            var viewModelLoader = Mvx.IoCProvider.Resolve <IMvxViewModelLoader>();

            ViewModel = (MeViewModel)viewModelLoader.LoadViewModel(new MvxViewModelRequest <MeViewModel>(), null);

            InitializeComponent();
        }
        public IActionResult Get()
        {
            var id = User.FindFirst(ClaimTypes.NameIdentifier).Value;

            var model = new MeViewModel()
            {
                Customer       = _customerService.getCustomerByUniqueID(id.ToString()),
                AccountNumbers = _accountService.getAccountsByCustomerID(Int32.Parse(id.ToString()))
            };

            return(Ok(model));
        }
Exemple #8
0
 public MePage()
 {
     MeViewModel = new MeViewModel();
     InitializeComponent();
     flip.AddHandler(PointerWheelChangedEvent, new PointerEventHandler(OnChanged), true);
     _tt = header.RenderTransform as TranslateTransform;
     if (_tt == null)
     {
         //似乎是在这里将位移值给页面
         header.RenderTransform = _tt = new TranslateTransform();
     }
 }
        public IActionResult Index()
        {
            var meViewModel = new MeViewModel();

            if (_db.Students.Any(x => x.UserId == _userId))
            {
                meViewModel.Student = _db.Students.FirstOrDefault(x => x.UserId == _userId);
            }
            if (_db.UserScores.Any(x => x.UserId == _userId))
            {
                meViewModel.UserScore = _db.UserScores.First(x => x.UserId == _userId);
            }

            return(View(meViewModel));
        }
Exemple #10
0
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            if (Vm != null && _isPresentedFirstTime)
            {
                _isPresentedFirstTime = false;
                await Vm.NavigateCommand.ExecuteAsync(typeof(HomeViewModel));

                // Set the titlebar
                var textColor = ActualTheme == ElementTheme.Dark
                    ? Colors.White
                    : Colors.Black;

                // Extend UI
                CoreApplication.GetCurrentView().TitleBar.ExtendViewIntoTitleBar = true;

                // Set custom titlebar
                AppTitle.Foreground = new SolidColorBrush(textColor);
                Window.Current.SetTitleBar(Titlebar);

                // Update Title bar colors
                ApplicationView.GetForCurrentView().TitleBar.ButtonBackgroundColor = Colors.Transparent;
                ApplicationView.GetForCurrentView().TitleBar.ButtonHoverBackgroundColor =
                    new Color {
                    R = 0, G = 0, B = 0, A = 20
                };
                ApplicationView.GetForCurrentView().TitleBar.ButtonPressedBackgroundColor =
                    new Color {
                    R = 0, G = 0, B = 0, A = 60
                };
                ApplicationView.GetForCurrentView().TitleBar.ButtonInactiveBackgroundColor = Colors.Transparent;
                ApplicationView.GetForCurrentView().TitleBar.ForegroundColor = textColor;
                ApplicationView.GetForCurrentView().TitleBar.ButtonForegroundColor = textColor;
                ApplicationView.GetForCurrentView().TitleBar.ButtonHoverForegroundColor = textColor;
                ApplicationView.GetForCurrentView().TitleBar.ButtonPressedForegroundColor = textColor;

                // Set up the "Me" View model, on mobile apps / xbox this is a seperate page, but
                // on PC, this is included in the root view.

                // Load the viewModel
                var viewModelLoader = Mvx.IoCProvider.Resolve <IMvxViewModelLoader>();
                MeVm = (MeViewModel)viewModelLoader.LoadViewModel(new MvxViewModelRequest <MeViewModel>(), null);

                Vm.GetPlaybackService().OnMediaChange += RootView_OnMediaChange;
            }
        }
Exemple #11
0
        public void TestCheckCommandOther()
        {
            var messageToShow = "Error Message";

            var rootFrameNavigated         = false;
            var stubIRootNavigationService = new StubIRootNavigationService();

            stubIRootNavigationService.Navigate(
                (sourcePageType, parameter, navigationTransition) =>
                rootFrameNavigated = true);

            var messageShown       = "";
            var dialogShown        = false;
            var stubIDialogService = new StubIDialogService();

            stubIDialogService.ShowAsync(async message => {
                dialogShown  = true;
                messageShown = message;
            });

            var getMeRequested      = false;
            var stubIStudentService = new StubIStudentService();

            stubIStudentService.GetMeAsync(async() => {
                getMeRequested = true;
                return(new ServiceResult <Student> {
                    Status = ServiceResultStatus.Exception,
                    Message = messageToShow
                });
            });

            var meViewModel =
                new MeViewModel(stubIStudentService, stubIDialogService);

            meViewModel.GetCommand.Execute(null);

            Assert.IsFalse(rootFrameNavigated);
            Assert.IsTrue(dialogShown);
            Assert.AreEqual(
                UvpClient.App.HttpClientErrorMessage + messageToShow,
                messageShown);
            Assert.IsTrue(getMeRequested);
        }
        public async Task <IActionResult> Index()
        {
            if (_dataCookies.TryGetPlayerCode(out var code))
            {
                var player = await _playerData.Get(code);

                if (player != null)
                {
                    var vm = new MeViewModel
                    {
                        Code = player.Code,
                        Name = player.Name
                    };
                    return(View(vm));
                }
            }

            _logger.LogInformation("New player");

            return(RedirectToAction("New", "Players", new { returnUrl = Url.Action("Index") }));
        }
Exemple #13
0
        public IHttpActionResult PutUser(MeViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var user = UserManager.FindById(User.Identity.GetUserId());

            if (user == null)
            {
                return(BadRequest());
            }

            // Mapper.Map<MeViewModel, ApplicationUser>(viewModel, user);
            user.Person.LastName   = viewModel.LastName;
            user.Person.FirstName  = viewModel.FirstName;
            user.Person.MiddleName = viewModel.MiddleName;
            user.Person.Birthday   = viewModel.Birthday;
            UserManager.Update(user);

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemple #14
0
        public void TestGetCommandSucceeded()
        {
            var studentToReturn = new Student();

            var rootFrameNavigated         = false;
            var stubIRootNavigationService = new StubIRootNavigationService();

            stubIRootNavigationService.Navigate(
                (sourcePageType, parameter, navigationTransition) =>
                rootFrameNavigated = true);

            var dialogShown        = false;
            var stubIDialogService = new StubIDialogService();

            stubIDialogService.ShowAsync(async message => dialogShown = true);

            var getMeRequested      = false;
            var stubIStudentService = new StubIStudentService();

            stubIStudentService.GetMeAsync(async() => {
                getMeRequested = true;
                return(new ServiceResult <Student>
                {
                    Status = ServiceResultStatus.OK, Result = studentToReturn
                });
            });

            var meViewModel =
                new MeViewModel(stubIStudentService, stubIDialogService);

            meViewModel.GetCommand.Execute(null);

            Assert.IsFalse(rootFrameNavigated);
            Assert.IsFalse(dialogShown);
            Assert.IsTrue(getMeRequested);
            Assert.AreSame(studentToReturn, meViewModel.Me);
        }
Exemple #15
0
 public MeView()
 {
     InitializeComponent();
     BindingContext = new MeViewModel();
 }
Exemple #16
0
        public MePage()
        {
            InitializeComponent();

            DataContext = _vm = (Application.Current as App).Container.GetRequiredService <MeViewModel>();
        }