public AccountPageViewModel MyAccounts(string id, int page) { var result = new AccountPageViewModel(); try { var client = _dbContext.Clients.Single(c => c.ApplicationUserId == id); int pageToQuantity = 10; result.Accounts = _dbContext.Accounts .OrderBy(x => x.CreatedAt) .Skip((page - 1) * pageToQuantity) .Take(pageToQuantity) .Include(x => x.Client) .Where(x => x.ClientId == client.Id); result.ActuallyPage = page; result.TotalOfRegister = _dbContext.Accounts .Where(x => x.ClientId == client.Id).Count(); result.RegisterByPage = pageToQuantity; } catch (Exception e) { return(new AccountPageViewModel()); } return(result); }
//[AllowAnonymous] public ActionResult AccountPage() //帳戶主頁面 { AccountPageViewModel model = new AccountPageViewModel(); var userID = User.Identity.GetUserId(); model.User = db.AspNetUsers.FirstOrDefault(x => x.Id == userID); if (db.Orders.Any(x => x.UserID == userID)) { List <Order> orders = db.Orders.Where(x => x.UserID == userID).OrderByDescending(x => x.OrderID).ToList(); model.Orders = orders; List <OrderDetail> orderDetails = new List <OrderDetail>(); List <Image> images = new List <Image>(); int endIndext = 0; string PDIDtoFindImg = string.Empty; foreach (var item in orders) { var thisOrderDetails = db.OrderDetails.Where(x => x.OrderID == item.OrderID).ToList(); foreach (var sonitem in thisOrderDetails) { orderDetails.Add(sonitem); endIndext = sonitem.PDID.IndexOf("-"); PDIDtoFindImg = sonitem.PDID.Substring(0, endIndext) + "-1"; if (!images.Any(x => x.PDID == PDIDtoFindImg)) { images.Add(db.Images.First(x => x.PDID == PDIDtoFindImg)); } } } model.OrderDetails = orderDetails; model.images = images; } ViewBag.City = new SelectList(ConstantData.Citys, model.User.City); return(View(model)); }
protected override void OnLaunched(LaunchActivatedEventArgs e) { // smooth merchant thumbnail image resizing new BitmapTransform().InterpolationMode = BitmapInterpolationMode.Cubic; Frame rootFrame = Window.Current.Content as Frame; if (rootFrame == null) { rootFrame = new Frame(); rootFrame.NavigationFailed += OnNavigationFailed; Window.Current.Content = rootFrame; } if (rootFrame.Content == null) { var navigationService = new NavigationService(rootFrame); var loginPageViewModel = new LoginPageViewModel(); var accountPageViewModel = new AccountPageViewModel(); var schedulerService = new SchedulerService(); var mondoAuthorizationClient = new MondoAuthorizationClient("YOUR_CLIENT_ID_HERE", "YOUR_CLIENT_SECRET_HERE", "https://production-api.gmon.io"); var appController = new AppController(navigationService, mondoAuthorizationClient, loginPageViewModel, accountPageViewModel, schedulerService); appController.Start(); rootFrame.Navigate(typeof(LoginPage), e.Arguments); rootFrame.DataContext = loginPageViewModel; } Window.Current.Activate(); }
private async Task<AccountPageViewModel> AddAccountAsync(string accountTitle) { var categoryPage = _viewModelLocator.CategoryPage; // Add account to the category All. _windowManager.InputDialogResult = accountTitle; Assert.IsTrue(categoryPage.AddAccountCommand.CanExecute(null)); categoryPage.AddAccountCommand.Execute(null); categoryPage.AddAccountCommand.WaitRunToCompletion(); await Task.Delay(1000).ConfigureAwait(false); // Wait to be sure the AccountPageViewModel got initialized. AccountPageViewModel accountPage = null; await TaskHelper.RunOnUIThreadAsync(() => { var ui = ((AccountPage)((CategoryPage)_mainPageFrame.Content).AccountFrame.Content); ui.UpdateLayout(); accountPage = ui.ViewModel; accountPage.WindowManager = _windowManager; }).ConfigureAwait(false); Assert.IsTrue(accountPage.IsEditing); return accountPage; }
public async Task MoveAccountDataUp() { AccountPageViewModel accountPage = await AddAccountAsync("Account 1").ConfigureAwait(false); // Adding 3 account data. var controls = new List<AccountDataControl> { await AddAccountDataAsync(accountPage, typeof(CredentialData)).ConfigureAwait(false), await AddAccountDataAsync(accountPage, typeof(CredentialData)).ConfigureAwait(false), await AddAccountDataAsync(accountPage, typeof(CredentialData)).ConfigureAwait(false) }; var originalListOfData = accountPage.AccountEditMode.Data.ToList(); // Move the last item up. await TaskHelper.RunOnUIThreadAsync(() => { Assert.IsTrue(controls[2].MoveUpCommand.CanExecute(null)); controls[2].MoveUpCommand.Execute(null); }).ConfigureAwait(false); // The first item didn't move. Assert.AreEqual(originalListOfData[0].Id, accountPage.AccountEditMode.Data[0].Id); // The middle item is now the last. Assert.AreEqual(originalListOfData[1].Id, accountPage.AccountEditMode.Data[2].Id); // The last item is now in the middle. Assert.AreEqual(originalListOfData[2].Id, accountPage.AccountEditMode.Data[1].Id); }
public AccountPageViewModel Search(string parameter, int page) { var result = new AccountPageViewModel(); try { int pageToQuantity = 10; result.Accounts = _dbContext.Accounts .OrderBy(x => x.Name) .Where(x => x.Name.Contains(parameter) || x.Client.Name.Contains(parameter)) .Skip((page - 1) * pageToQuantity) .Take(pageToQuantity) .Include(x => x.Client) .ToList(); var totalOfAccount = _dbContext.Accounts .Where(x => x.Name.Contains(parameter) || x.Client.Name.Contains(parameter)) .Count(); result.ActuallyPage = page; result.TotalOfRegister = totalOfAccount; result.RegisterByPage = pageToQuantity; } catch (Exception) { result = null; } return(result); }
public AccountPage() { InitializeComponent(); homeNameEntry.Name = "HomeName"; homeAddressEntry.Name = "HomeAddress"; noConnectionLabel.Text = noConnectionLabel.Text.Insert(0, "-"); BindingContext = viewModel = new AccountPageViewModel(); searchEntry.ReturnCommand = new Command(() => SearchButton(this, null)); }
public AppController( INavigationService navigationService, IMondoAuthorizationClient mondoAuthorizationClient, LoginPageViewModel loginPageViewModel, AccountPageViewModel accountPageViewModel, ISchedulerService schedulerService) { _navigationService = navigationService; _mondoAuthorizationClient = mondoAuthorizationClient; _loginPageViewModel = loginPageViewModel; _accountPageViewModel = accountPageViewModel; _schedulerService = schedulerService; }
public async Task AccountTab_NavigationsHasBeenLoaded_Pass() { //Arrange AccountPageViewModel accountPageViewModel = new AccountPageViewModel(this.container.Resolve <IPageDialogService>(), this.container.Resolve <IAuthenticationFacade>(), this.container.Resolve <INavigationService>(), this.container.Resolve <IPropertyFacade>(), SetupHelper.CreateFakeKeyChain(this.container)); await Task.Delay(2000); //Assert Assert.Equal(accountPageViewModel.Navigations.Count, 5); }
public NavigationViewModel() { AllItems = new VaultPage("All items"); FavoriteItems = new FavoritesVaultPage(); CategoryItems.Add(new CategoryVaultPage("Login", "LoginIcon", typeof(LoginItem))); CategoryItems.Add(new CategoryVaultPage("Note", "NoteIcon", typeof(NoteItem))); CategoryItems.Add(new CategoryVaultPage("Card", "CardIcon", typeof(CardItem))); CategoryItems.Add(new CategoryVaultPage("Identity", "IdentityIcon", typeof(IdentityItem))); Settings = new SettingsPageViewModel(); Account = new AccountPageViewModel(); UpdateFolders(); BitwardenFoldersRepository.Instance.PropertyChanged += Folders_PropChanged; }
public async Task SaveAccountWithEmptyNameAsync() { AccountPageViewModel accountPage = await AddAccountAsync("Account 1").ConfigureAwait(false); Assert.IsTrue(accountPage.IsEditing); // Clear the title field. accountPage.AccountEditMode.Title = string.Empty; // Try to save. accountPage.SaveChangesCommand.Execute(null); accountPage.SaveChangesCommand.WaitRunToCompletion(); // The action has been canceled because there is no title. Therefore the account should still be in Editing mode. Assert.IsTrue(accountPage.IsEditing); }
public async Task AddAccountData() { AccountPageViewModel accountPage = await AddAccountAsync("Account 1").ConfigureAwait(false); // Adding 3 account data. await AddAccountDataAsync(accountPage, typeof(CredentialData)).ConfigureAwait(false); await AddAccountDataAsync(accountPage, typeof(CredentialData)).ConfigureAwait(false); await AddAccountDataAsync(accountPage, typeof(CredentialData)).ConfigureAwait(false); var accountData = accountPage.AccountPageToAccountDataViewModelBridge.ViewModels; Assert.AreEqual(3, accountData.Count); Assert.IsTrue(accountData[0].IsEditing); Assert.IsTrue(accountData[1].IsEditing); Assert.IsTrue(accountData[2].IsEditing); }
public void GetBlikCodeCommand__ShouldNotNavigateOnInvalidCredentials(string username) { // ARRANGE var parameters = new NavigationParameters { { nameof(username), username }, }; var mockNavigationService = new Mock <INavigationService>(); var viewModel = new AccountPageViewModel(mockNavigationService.Object); // ACT Should.NotThrow(() => viewModel.OnNavigatingTo(parameters)); // ASSERT viewModel.GetBlikCodeCommand.CanExecute().ShouldBeFalse(); }
protected override void OnAppearing() { base.OnAppearing(); if (HadInitilize == true) { return; } HadInitilize = true; BindingContext = viewModel = new AccountPageViewModel(); // upate tu profile page. MessagingCenter.Subscribe <ProfilePage, string>(this, "UpdateAvatar", (sender, avatar) => { viewModel.User.AvatarUrl = avatar; image.Source = viewModel.User.AvatarFullUrl; }); MessagingCenter.Subscribe <ProfilePageViewModel, User>(this, "UpdateProfile", (sender, user) => { viewModel.User = user; image.Source = viewModel.User.AvatarFullUrl; }); MessagingCenter.Subscribe <SocialLinkedPageViewModel, User>(this, "UpdateSocialLinked", async(sender, arg) => { viewModel.User = arg; viewModel.SocialCount = 0; if (viewModel.User.FacebookId != -1 && !string.IsNullOrEmpty(viewModel.User.FacebookId.ToString())) { viewModel.SocialCount++; } if (viewModel.User.ZaloId != -1 && !string.IsNullOrEmpty(viewModel.User.ZaloId.ToString())) { viewModel.SocialCount++; } if (!string.IsNullOrEmpty(viewModel.User.GoogleId)) { viewModel.SocialCount++; } }); //LabelLanguage.Text = AppShell.Languages[LanguageSettings.Language]; }
private async Task<AccountDataControl> AddAccountDataAsync(AccountPageViewModel accountPage, Type accountDataType) { var accountDataProviders = _app.ExportProvider.GetExports<Lazy<IAccountDataProvider, AccountDataProviderMetadata>>(); var provider = accountDataProviders.Single(p => p.Metadata.AccountDataType == accountDataType); // Adding 3 account data. Assert.IsTrue(accountPage.AddAccountDataCommand.CanExecute(provider.Value)); accountPage.AddAccountDataCommand.Execute(provider.Value); accountPage.AddAccountDataCommand.WaitRunToCompletion(); AccountDataControl ui = null; await TaskHelper.RunOnUIThreadAsync(() => { ui = new AccountDataControl(); ui.AccountPageToAccountDataViewModelBridge = accountPage.AccountPageToAccountDataViewModelBridge; ui.DataContext = accountPage.AccountEditMode.Data.Last(); }).ConfigureAwait(false); return ui; }
public void OnNavigatingTo__ParserNavigationParametersCorrectly(string username) { // ARRANGE var parameters = new NavigationParameters { { nameof(username), username }, }; var mockNavigationService = new Mock <INavigationService>(); mockNavigationService.Setup(n => n.NavigateAsync($"/{nameof(SignInPage)}")) .ReturnsAsync(new Mock <INavigationResult>().Object); var viewModel = new AccountPageViewModel(mockNavigationService.Object); // ACT Should.NotThrow(() => viewModel.OnNavigatingTo(parameters)); // ASSERT viewModel.Username.ShouldBeSameAs(username ?? string.Empty); }
public void OnNavigatingTo__NavigatesToSignInPageOnInvalidCredentials(string username) { // ARRANGE var parameters = new NavigationParameters { { nameof(username), username }, }; var mockNavigationService = new Mock <INavigationService>(); mockNavigationService.Setup(n => n.NavigateAsync($"/{nameof(SignInPage)}")) .ReturnsAsync(new Mock <INavigationResult>().Object); var viewModel = new AccountPageViewModel(mockNavigationService.Object); // ACT Should.NotThrow(() => viewModel.OnNavigatingTo(parameters)); // ASSERT mockNavigationService.Verify(n => n.NavigateAsync($"/{nameof(SignInPage)}"), Times.Once); }
public async Task AccountTab_NavigationCheck_Pass() { var navigationService = this.container.Resolve <INavigationService>(); //Arrange AccountPageViewModel accountPageViewModel = new AccountPageViewModel(this.container.Resolve <IPageDialogService>(), this.container.Resolve <IAuthenticationFacade>(), navigationService, this.container.Resolve <IPropertyFacade>(), SetupHelper.CreateFakeKeyChain(this.container)); await Task.Delay(2000); accountPageViewModel.ItemTappedCommand.Execute(new NavigationItemViewModel() { Name = "Property Details", NavigationUrl = "PropertyDetailsPage", ItemTappedCommand = new DelegateCommand <NavigationItemViewModel>((nav) => { nav.LeaseId = new Guid("af32a4fb-ec71-4f94-a2d6-0005a9b6e2f2"); var navigationParams = new NavigationParameters(); navigationParams.Add(MagicStrings.Lease, accountPageViewModel.SelectedProperty); navigationService.NavigateAsync(nav.NavigationUrl, navigationParams, false, true); }) }); var navigation = navigationService as NavigationServiceMock; Assert.NotNull(navigation); var navUrl = navigation.LastNavigationUrl; //Assert Assert.Equal(navUrl, "PropertyDetailsPage"); }
public AccountPageViewModel GetAllByPage(int page = 1) { var result = new AccountPageViewModel(); try { int pageToQuantity = 10; result.Accounts = _dbContext.Accounts .OrderBy(x => x.Name) .Skip((page - 1) * pageToQuantity) .Take(pageToQuantity) .Include(x => x.Client) .ToList(); var totalOfAccount = _dbContext.Accounts.Count(); result.ActuallyPage = page; result.TotalOfRegister = totalOfAccount; result.RegisterByPage = pageToQuantity; } catch (Exception) { result = null; } return(result); }
public void GetBlikCodeCommand__ShouldNavigateToCorrectViewOnValidCredentials(string username) { // ARRANGE var parameters = new NavigationParameters { { nameof(username), username }, }; var mockNavigationService = new Mock <INavigationService>(); mockNavigationService.Setup(n => n.NavigateAsync($"{nameof(BlikCodePage)}", new NavigationParameters($"{nameof(username)}={username}"))) .ReturnsAsync(new Mock <INavigationResult>().Object); var viewModel = new AccountPageViewModel(mockNavigationService.Object); // ACT Should.NotThrow(() => viewModel.OnNavigatingTo(parameters)); Should.NotThrow(viewModel.GetBlikCodeCommand.Execute); // ASSERT mockNavigationService.Verify(n => n.NavigateAsync($"{nameof(BlikCodePage)}", new NavigationParameters($"{nameof(username)}={username}")), Times.Once); }
public AccountPage(int userId, Action _logoutAction, ParkingManager pk) { InitializeComponent(); DataContext = new AccountPageViewModel(userId, _logoutAction, pk); }
public async Task DeleteAccountData() { AccountPageViewModel accountPage = await AddAccountAsync("Account 1").ConfigureAwait(false); // Adding 3 account data. var controls = new List<AccountDataControl> { await AddAccountDataAsync(accountPage, typeof(CredentialData)).ConfigureAwait(false), await AddAccountDataAsync(accountPage, typeof(CredentialData)).ConfigureAwait(false), await AddAccountDataAsync(accountPage, typeof(CredentialData)).ConfigureAwait(false) }; // Save changes. accountPage.SaveChangesCommand.Execute(null); accountPage.SaveChangesCommand.WaitRunToCompletion(); Assert.AreEqual(3, accountPage.Account.Data.Count); // Go to Edit mode. accountPage.EditAccountCommand.Execute(null); accountPage.EditAccountCommand.WaitRunToCompletion(); Assert.AreEqual(3, accountPage.AccountEditMode.Data.Count); // Delete the first item. await TaskHelper.RunOnUIThreadAsync(() => { Assert.IsTrue(controls[0].DeleteCommand.CanExecute(null)); controls[0].DeleteCommand.Execute(null); }).ConfigureAwait(false); Assert.AreEqual(3, accountPage.Account.Data.Count); Assert.AreEqual(2, accountPage.AccountEditMode.Data.Count); // Cancel the change. accountPage.DiscardChangesCommand.Execute(null); Assert.AreEqual(3, accountPage.Account.Data.Count); // Go to Edit mode. accountPage.EditAccountCommand.Execute(null); accountPage.EditAccountCommand.WaitRunToCompletion(); Assert.AreEqual(3, accountPage.AccountEditMode.Data.Count); // Delete the first item. await TaskHelper.RunOnUIThreadAsync(() => { Assert.IsTrue(controls[0].DeleteCommand.CanExecute(null)); controls[0].DeleteCommand.Execute(null); }).ConfigureAwait(false); Assert.AreEqual(3, accountPage.Account.Data.Count); Assert.AreEqual(2, accountPage.AccountEditMode.Data.Count); // Save changes. accountPage.SaveChangesCommand.Execute(null); accountPage.SaveChangesCommand.WaitRunToCompletion(); Assert.AreEqual(2, accountPage.Account.Data.Count); }
protected override void OnAppearing() { BindingContext = new AccountPageViewModel(); base.OnAppearing(); }
/// <summary> /// Initialize a new instance of the <see cref="AccountPageToAccountDataViewModelBridge"/> class. /// </summary> /// <param name="accountPageViewModel">The <see cref="AccountPageViewModel"/>.</param> internal AccountPageToAccountDataViewModelBridge(AccountPageViewModel accountPageViewModel) { _accountPageViewModel = Arguments.NotNull(accountPageViewModel, nameof(accountPageViewModel)); _accountPageViewModel.PropertyChanged += AccountPageViewModel_PropertyChanged; }