Exemplo n.º 1
0
 public TestViewModel(IPopupNavigationService popupNavigationService)
 {
     Close = new BitDelegateCommand(async() =>
     {
         await popupNavigationService.PopAsync();
     });
 }
Exemplo n.º 2
0
 public ChallengeViewModel(IMvxNavigationService navigationService, IStorageHelper storageHelper, IMessagingCenter messagingCenter, IPopupNavigationService popupNavigationService)
 {
     _navigationService      = navigationService;
     _storageHelper          = storageHelper;
     _messagingCenter        = messagingCenter;
     _popupNavigationService = popupNavigationService;
     _challengeList          = new MvxObservableCollection <Challenge>();
 }
Exemplo n.º 3
0
        public LoginViewModel(
            IMvxNavigationService navigationService,
            IStorageHelper storageHelper,
            ILoginService loginService,
            IChallengeService challengeService,
            IMessagingCenter messagingCenter,
            IPopupNavigationService popupNavigationService
            )
        {
            _navigationService      = navigationService;
            _storageHelper          = storageHelper;
            _loginService           = loginService;
            _challengeService       = challengeService;
            _messagingCenter        = messagingCenter;
            _popupNavigationService = popupNavigationService;

            LoginCommand          = new MvxAsyncCommand(LoginAsync);
            ForgotPasswordCommand = new MvxAsyncCommand(ForgotPassword);
            InstagramCommand      = new MvxAsyncCommand(RedirectInstagram);
            FacebookCommand       = new MvxAsyncCommand(RedirectFacebook);
            RegisterCommand       = new MvxAsyncCommand(RedirectRegister);
        }
Exemplo n.º 4
0
        public MainViewModel(INavigationService navigationService,
                             SampleDbContext dbContext,
                             ISyncService syncService,
                             IODataClient oDataClient,
                             HttpClient httpClient,
                             ISecurityService securityService,
                             IPopupNavigationService popupNavigationService)
        {
            SendHttpRequest = new BitDelegateCommand(async() =>
            {
                using (HttpResponseMessage response = await httpClient.GetAsync("odata/Test/parentEntities"))
                {
                }
            });

            SendODataRequest = new BitDelegateCommand(async() =>
            {
                var result = await oDataClient.For("ParentEntities").FindEntriesAsync();
            });

            Logout = new BitDelegateCommand(async() =>
            {
                await securityService.Logout();
                await navigationService.NavigateAsync("/Login");
            });

            ShowPopup = new BitDelegateCommand(async() =>
            {
                await popupNavigationService.PushAsync("Test");
            });

            Sync = new BitDelegateCommand(async() =>
            {
                await dbContext.Database.EnsureDeletedAsync();
                await dbContext.Database.EnsureCreatedAsync();

                await oDataClient.For <TestCustomerDto>("TestCustomers")
                .Set(new TestCustomerDto {
                    Id = Guid.NewGuid(), Name = "A1", CityId = Guid.Parse("EF529174-C497-408B-BB4D-C31C205D46BB"), Kind = TestCustomerKind.Type1
                })
                .InsertEntryAsync();

                await oDataClient.For <TestCustomerDto>("TestCustomers")
                .Set(new TestCustomerDto {
                    Id = Guid.NewGuid(), Name = "A2", CityId = Guid.Parse("EF529174-C497-408B-BB4D-C31C205D46BB"), Kind = TestCustomerKind.Type1
                })
                .InsertEntryAsync();

                await syncService.SyncContext();

                TestCustomerDto customer = await dbContext.TestCustomers.FirstAsync();
                customer.Name           += "?";
                dbContext.Update(customer);
                await dbContext.SaveChangesAsync();

                await oDataClient.For <TestCustomerDto>("TestCustomers")
                .Set(new TestCustomerDto {
                    Id = Guid.NewGuid(), Name = "A3", CityId = Guid.Parse("EF529174-C497-408B-BB4D-C31C205D46BB"), Kind = TestCustomerKind.Type1
                })
                .InsertEntryAsync();

                await oDataClient.For <TestCustomerDto>("TestCustomers")
                .Set(new TestCustomerDto {
                    Id = Guid.NewGuid(), Name = "A4", CityId = Guid.Parse("EF529174-C497-408B-BB4D-C31C205D46BB"), Kind = TestCustomerKind.Type1
                })
                .InsertEntryAsync();

                await syncService.SyncContext();

                await dbContext.Entry(customer).ReloadAsync();

                dbContext.Remove(customer);

                await dbContext.SaveChangesAsync();

                await syncService.SyncContext();
            });
        }