public AccountInfoViewModel(IProfileProvider profileProvider, ICredentialsProvider credentialsProvider, IDataCacheService dataCacheService, IFileCacheService fileCacheService, INavigationService navigationService,
            INotificationsProvider notificationsProvider, IBookmarksProvider bookmarksProvider, ICatalogProvider catalogProvider, IBookProvider bookProvider, ICatalitClient client, ILitresPurchaseService purchaseService)
        {
			_navigationService = navigationService;
			_profileProvider = profileProvider;
			_credentialsProvider = credentialsProvider;
			_dataCacheService = dataCacheService;
			_fileCacheService = fileCacheService;
			_notificationsProvider = notificationsProvider;
			_bookmarksProvider = bookmarksProvider;
			_catalogProvider = catalogProvider;
            _bookProvider = bookProvider;
            _client = client;
            _purchaseService = purchaseService;
            RegisterAction(ClearUserInfoPart).AddPart(ClearUserInfoProceed, session => true);
            RegisterAction(AddToDepositPart).AddPart(AddToDepositProceed, session => true);
            RegisterAction(LoadUserInfoPart).AddPart(LoadUserInfoProceed, session => session.Parameters.GetValue<UserInformation>(ChangeUserInfoParameter, null) == null);

            ClearData = new RelayCommand(ClearUserInfo);

            ReloadInfo = new RelayCommand(ReloadUserInfo);

            AddToDeposit = new RelayCommand<DepositType>(dt => AddToDepositFunc(dt));


            Deposits = new List<Deposit> { 
                                       new Deposit { LitresPrice = "105 руб.", RealPrice = "149 руб." }, 
                                       new Deposit { LitresPrice = "189 руб.", RealPrice = "269 руб." }, 
                                       new Deposit { LitresPrice = "304 руб.", RealPrice = "434 руб." }};
		}
		public NotificationsViewModel( INotificationsProvider notificationsProvider, INavigationService navigationService )
		{
			_notificationsProvider = notificationsProvider;
			_navigationService = navigationService;

            RegisterAction(DeleteNotificationPart).AddPart(session => DeleteNotificationsProceed(session), session => true);
            RegisterAction(MainPart).AddPart(session => LoadNotifications(session), session => true);

			Notifications = new XCollection<Notification>();

			ShowNotificationsEdit = new RelayCommand( () => _navigationService.Navigate( "NotificationsEdit" ) );
			//CancelEdit = new RelayCommand( () => _navigationService.GoBack() );
			NotificationSelected = new RelayCommand<Notification>( NavigateToObject, notification => notification != null );
			DeleteNotifications = new RelayCommand<XCollection<Notification>>( DeleteNotificationsCalled, notifications => notifications != null );
		}
Exemplo n.º 3
0
		public BookmarksViewModel(IBookmarksProvider bookmarksProvider, ICatalogProvider catalogProvider, INavigationService navigationService)
		{
			_bookmarksProvider = bookmarksProvider;
			_catalogProvider = catalogProvider;
			_navigationService = navigationService;

			RegisterPart( MainPart, ( session, part ) => LoadBookmarks( session ), ( session, part ) => true );
			//RegisterPart( DeletePart, ( session, part ) => DeleteBookmarks( session ), ( session, part ) => true, false );


			Bookmarks = new XCollection<Bookmark>();
			BookmarkedBooks = new XCollection<Book>();

			BookSelected = new RelayCommand<Book>( book => _navigationService.Navigate( "BookBookmarks", Parameters.From( "id", book.Id )), book => book != null );
		}
        //public RelayCommand LoadMoreCalled { get; private set; }

		#region Constructors/Disposer
        public FreeBooksByCategoryViewModel(ICatalogProvider catalogProvider, INavigationService navigationService)
		{
			_catalogProvider = catalogProvider;
			_navigationService = navigationService;

            PopularBooks = new XCollection<Book>();
            NoveltyBooks = new XCollection<Book>();

            RegisterPart(MainPart, (session, part) => LoadBooks(session), (session, part) => !_loadedPopular && !_loadedNovelty, true);
            //RegisterPart( LoadMorePart, ( session, part ) => LoadBooks( session ), ( session, part ) => !_isEndOfList, false );

            RegisterPart(LoadMoreNoveltyBooksPart, (session, part) => LoadNoveltyBooks(session), (session, part) => !_isEndOfListNoveltyBooks, false);
            RegisterPart(LoadMorePopularBooksPart, (session, part) => LoadPopularBooks(session), (session, part) => !_isEndOfListPopularBooks, false);

			//Books = new XCollection<Book>();

			BookSelected = new RelayCommand<Book>(book => _navigationService.Navigate("Book", Parameters.From("id", book.Id)), book => book != null);

            LoadMoreNoveltyBooks = new RelayCommand(LoadMoreNoveltyBooksProceed, () => true);
            LoadMorePopularBooks = new RelayCommand(LoadMorePopularBooksProceed, () => true);

			//LoadMoreCalled = new RelayCommand(() => LoadMore(), () => true);
		}
Exemplo n.º 5
0
		public PersonViewModel(ICredentialsProvider credentialsProvider, IPersonsProvider personsProvider, ICatalogProvider catalogProvider, INavigationService navigationService, IRecensesProvider recensesProvider, INotificationsProvider notificationsProvider, ILitresPurchaseService litresPurchaseService, IProfileProvider profileProvider)
		{
			_credentialsProvider = credentialsProvider;
			_personsProvider = personsProvider;
			_catalogProvider = catalogProvider;
			_navigationService = navigationService;
			_recensesProvider = recensesProvider;
			_notificationsProvider = notificationsProvider;
		    _litresPurchaseService = litresPurchaseService;
		    _profileProvider = profileProvider;

		    PersonBooks = new XCollection<Book>();
			PersonRecenses = new XCollection<Recense>();

            RegisterAction(LoadMorePart).AddPart(session => LoadPersonBooks(session, Entity), session => true);
            RegisterAction(ChangeNotificationStatusPart).AddPart(session => ChangeNotificationStatus(session), session => true);
            RegisterAction(LoadMainPart).AddPart(session => LoadPerson(session), session => true);
            RegisterAction(AddPersonRecensePart).AddPart((session) => AddPersonRecense(session), (session) => true);
            RegisterAction(BuyBookLitresPart).AddPart((session) => BuyBookFromLitres(session, Book), (session) => true);
            RegisterAction(CreditCardInfoPart).AddPart(session => CreditCardInfoAsync(session), (session) => true);
            RegisterAction(BuyBookPart).AddPart((session) => BuyBookAsync(session, Book), (session) => true);

            LoadMoreCalled = new RelayCommand( () => LoadMore(), () => true );
			BookSelected = new RelayCommand<Book>( NavigateToBook, book => book != null );
			WriteRecenseSelected = new RelayCommand( () => _navigationService.Navigate( "AddRecense", XParameters.Create( "personId", Entity.Id ) ), () => Entity != null );
            BuyBook = new RelayCommand<Book>(book => BuyBookFromLitresAsync(book));
            RunCreditCardPaymentProcess = new RelayCommand(CreditCardInfo);
            ShowCreditCardView = new RelayCommand<Book>(book => _navigationService.Navigate("CreditCardPurchase", XParameters.Create("BookEntity", book)), book => book != null);
            BuyBookFromMicrosoft = new RelayCommand(BuyBookFromMicrosoftAsync);
            Read = new RelayCommand<Book>(book =>
            {
                if (!book.IsExpiredBook)
                    _navigationService.Navigate("Reader", XParameters.Create("BookEntity", book), false);
                else new MessageDialog("Истёк срок выдачи.").ShowAsync();
            });
        }
Exemplo n.º 6
0
        public MainViewModel(
         //   IExpirationGuardian expirationGuardian, 
            IProfileProvider profileProvider, 
            IGenresProvider genresProvider, 
            ICatalogProvider catalogProvider, 
            ICredentialsProvider credentialsProvider,
            IBookProvider bookProvider,
            INavigationService navigationService, 
            INetworkAvailabilityService networkAvailability,
            IDeviceInfoService deviceInfoService, ILitresPurchaseService litresPurchaseService)
        {            
            _genresProvider = genresProvider;
			_catalogProvider = catalogProvider;
			_credentialsProvider = credentialsProvider;
			_profileProvider = profileProvider;
			_bookProvider = bookProvider;
			_navigationService = navigationService;
		//    _expirationGuardian = expirationGuardian;
		    _networkAvailability = networkAvailability;
            _deviceInfoService = deviceInfoService;
            _litresPurchaseService = litresPurchaseService;

            var deviceFamily = _deviceInfoService.DeviceFamily;
            if (!string.IsNullOrEmpty(deviceFamily) && deviceFamily.Equals("Windows.Desktop"))
            {
                _booksPerPage = 30;
            }
            ////MyBooks reload allways, may change account information
            RegisterAction(BuyBookPart).AddPart((session) => BuyBookAsync(session, Book), (session) => true);
            RegisterAction(GiftBookPart).AddPart((session) => GetGiftAsync(session, Book), (session) => true);
            RegisterAction(MyBooksPart).AddPart( LoadMyBooks, session => true);
            RegisterAction(BuyBookLitresPart).AddPart((session) => BuyBookFromLitres(session, Book), (session) => true);
            RegisterAction(CreditCardInfoPart).AddPart(session => CreditCardInfoAsync(session), (session) => true);
            RegisterAction(LoadMoreNoveltyBooksPart).AddPart(session => LoadNoveltyBooks(session), session => true);
            RegisterAction(LoadMorePopularBooksPart).AddPart(session => LoadPopularBooks(session), session => true);
            RegisterAction(LoadMoreInterestingBooksPart).AddPart(session => LoadInterestingBooks(session), session => true);
            RegisterAction(MyOffersPart).AddPart(LoadOffers, session => true);
            //RegisterPart(MyBooksPart, (session, part) => LoadMyBooks(session), (session, part) => true, false);
            ////RegisterPart(NewBooksPart, (session, part) => LoadNewBooks(session), (session, part) => true, false);

            MyBooksViewState = MyBooksViewStateEnum.Loading;

			Genres = new XCollection<Genre>();
			Banners = new XCollection<Banner>();

			_myBooks = new XCollection<Book>();
			_noveltyBooks = new XCollection<Book>();
			_popularBooks = new XCollection<Book>();
			_interestingBooks = new XCollection<Book>();

			MyBooks = new XSubRangeCollection<Book>(_myBooks, 0, 10);
            
            NoveltyBooks = new XCollection<Book>();
			PopularBooks = new XCollection<Book>();
			InterestingBooks = new XCollection<Book>();
			ShowMyBooks = new RelayCommand( ToMyBooks );
            BookSelected = new RelayCommand<Book>(book =>  _navigationService.Navigate("Book", XParameters.Create("BookEntity", book)), book => book != null);
            BuyBook = new RelayCommand<Book>(BuyBookFromLitresAsync);
            GiftBook = new RelayCommand<Book>(GiftBookFromLitresAsync);
            ShowInterestingBooks = new RelayCommand(() => _navigationService.Navigate("BooksByCategory", XParameters.Create("category", (int) BooksByCategoryViewModel.BooksViewModelTypeEnum.Interesting)));
			ShowPopularBooks = new RelayCommand(() => _navigationService.Navigate("BooksByCategory", XParameters.Create("category", (int) BooksByCategoryViewModel.BooksViewModelTypeEnum.Popular)));
			ShowNewBooks = new RelayCommand(() => _navigationService.Navigate("BooksByCategory", XParameters.Create("category", (int) BooksByCategoryViewModel.BooksViewModelTypeEnum.Novelty)));
            LoadMoreNoveltyBooks = new RelayCommand(LoadMoreNoveltyBooksProceed, () => true);
            LoadMorePopularBooks = new RelayCommand(LoadMorePopularBooksProceed, () => true);
            LoadMoreInterestingBooks = new RelayCommand(LoadMoreInterestingBooksProceed, () => true);
            GenreSelected = new RelayCommand<int>(ChooseGenre);
			ShowSearchHistory = new RelayCommand(() => _navigationService.Navigate("Search"));
            BuyBookFromMicrosoft = new RelayCommand(BuyBookFromMicrosoftAsync);
            Read = new RelayCommand<Book>(book =>
            {
                if (!book.IsExpiredBook)
                    _navigationService.Navigate("Reader", XParameters.Create("BookEntity", book), false);
                else new MessageDialog("Истёк срок выдачи.").ShowAsync();
            });

            ShowAuthorization = new RelayCommand(() => _navigationService.Navigate("Authorization"));
            ShowRegistration = new RelayCommand(() => _navigationService.Navigate("Registration"));
			ShowUserInfo = new RelayCommand( ToUserInfo );
            RunCreditCardPaymentProcess = new RelayCommand(CreditCardInfo);
           
            ShowAccountInfo = new RelayCommand(ToAccountInfo);
			ShowSettings = new RelayCommand(() => _navigationService.Navigate("Settings"));
			ShowBookmarks = new RelayCommand( () => _navigationService.Navigate( "Bookmarks" ) );
			ShowAbout = new RelayCommand( () => _navigationService.Navigate( "About" ) );
			ShowNotifications = new RelayCommand(() => _navigationService.Navigate("NotificationsEdit"));
            ShowCreditCardView = new RelayCommand<Book>(book => _navigationService.Navigate("CreditCardPurchase", XParameters.Create("BookEntity", book)), book => book != null);

            ShowAppSettings = new RelayCommand(ToAppSettings);

            //_expirationGuardian.StartGuardian();		    
        }
Exemplo n.º 7
0
        public SearchViewModel(ICatalogProvider catalogProvider, INavigationService navigationService, ILitresPurchaseService litresPurchaseService, ICredentialsProvider credentialsProvider, IProfileProvider profileProvider)
        {
            _catalogProvider = catalogProvider;
            _navigationService = navigationService;
            _litresPurchaseService = litresPurchaseService;
            _credentialsProvider = credentialsProvider;
            _profileProvider = profileProvider;

            FoundBooks = new XCollection<Book>();
            FoundPersons = new XCollection<Person>();
            FoundSequeses = new XCollection<Book.SequenceInfo>();
           
            FirstBooks = new XSubRangeCollection<Book>(FoundBooks, 0, 3);
            FirstPersons = new XSubRangeCollection<Person>(FoundPersons, 0, 3);
            FirstSequeces = new XSubRangeCollection<Book.SequenceInfo>(FoundSequeses, 0, 3);
            //FoundCollections = new XCollection<Book.CollectionsInfo>();
            //FirstCollections = new XSubRangeCollection<Book.CollectionsInfo>(FoundCollections, 0, 3);

            TagsAndGenresCollection = new List<object>(6);
            BestResult = new List<object>();

            RegisterAction(LoadAllDataPart).AddPart(SearchAll, session => true);
            RegisterAction(BuyBookLitresPart).AddPart((session) => BuyBookFromLitres(session, Book), (session) => true);
            RegisterAction(CreditCardInfoPart).AddPart(session => CreditCardInfoAsync(session), (session) => true);
            RegisterAction(BuyBookPart).AddPart((session) => BuyBookAsync(session, Book), (session) => true);

            BuyBook = new RelayCommand<Book>(book => BuyBookFromLitresAsync(book));
            RunCreditCardPaymentProcess = new RelayCommand(CreditCardInfo);
            ShowCreditCardView = new RelayCommand<Book>(book => _navigationService.Navigate("CreditCardPurchase", XParameters.Create("BookEntity", book)), book => book != null);
            BuyBookFromMicrosoft = new RelayCommand(BuyBookFromMicrosoftAsync);

            BookSelected = new RelayCommand<Book>(book => _navigationService.Navigate("Book", XParameters.Create("BookEntity", book)), book => book != null);
            PersonSelected = new RelayCommand<Person>(person => _navigationService.Navigate("Person", XParameters.Create("Id", person.Id)), person => person != null);
            GenreSelected = new RelayCommand<Genre>(genre => _navigationService.Navigate("BooksByCategory", XParameters.Empty.ToBuilder()
                .AddValue("category", 6)
                .AddValue("id", int.Parse(genre.id))
                .AddValue("title", genre.name)
                .ToImmutable()), genre => genre != null);
            TagSelected = new RelayCommand<Tag>(tag => _navigationService.Navigate("BooksByCategory", XParameters.Empty.ToBuilder()
                .AddValue("category", 5)
                .AddValue("id", int.Parse(tag.id))
                .AddValue("title", tag.name)
                .ToImmutable()), tag => tag != null);
            SequenceSelected = new RelayCommand<Book.SequenceInfo>(sequence => _navigationService.Navigate("BooksByCategory", XParameters.Empty.ToBuilder()
                .AddValue("category", 7)
                .AddValue("id", sequence.Id)
                .AddValue("title", sequence.Name)
                .ToImmutable()), sequence => sequence != null);
            Read = new RelayCommand<Book>(book =>
            {
                if (!book.IsExpiredBook)
                    _navigationService.Navigate("Reader", XParameters.Create("BookEntity", book), false);
                else new MessageDialog("Истёк срок выдачи.").ShowAsync();
            });

            //CollectionSelected = new RelayCommand<Book.SequenceInfo>(sequence => _navigationService.Navigate("BooksByCategory", XParameters.Empty.ToBuilder()
            //    .AddValue("category", 8)
            //    .AddValue("id", sequence.Id)
            //    .AddValue("title", sequence.Name)
            //    .ToImmutable()), sequence => sequence != null);

            LoadMoreFoundBooks = new RelayCommand(() => Load(new Session()));
        }
        public BooksByCategoryViewModel(ICatalogProvider catalogProvider, INavigationService navigationService, ILitresPurchaseService litresPurchaseService, IProfileProvider profileProvider, ICredentialsProvider credentialsProvider)
		{
			_catalogProvider = catalogProvider;
			_navigationService = navigationService;
            _litresPurchaseService = litresPurchaseService;
            _profileProvider = profileProvider;
            _credentialsProvider = credentialsProvider;


            RegisterAction(MainPart).AddPart(session => LoadBooks(session), session => !_loaded);
            RegisterAction(LoadMorePart).AddPart(session => LoadBooks(session), session => !_isEndOfList);
            RegisterAction(BuyBookLitresPart).AddPart((session) => BuyBookFromLitres(session, Book), (session) => true);
            RegisterAction(CreditCardInfoPart).AddPart(session => CreditCardInfoAsync(session), (session) => true);
            RegisterAction(BuyBookPart).AddPart((session) => BuyBookAsync(session, Book), (session) => true);
            //RegisterPart( MainPart, ( session, part ) => LoadBooks( session ), ( session, part ) => !_loaded, true );
            //RegisterPart( LoadMorePart, ( session, part ) => LoadBooks( session ), ( session, part ) => !_isEndOfList, false );

            Books = new XCollection<Book>();

			BookSelected = new RelayCommand<Book>(book => _navigationService.Navigate("Book", XParameters.Create("BookEntity", book)), book => book != null);
			LoadMoreCalled = new RelayCommand(() => LoadMore(), () => true);
            BuyBook = new RelayCommand<Book>(book => BuyBookFromLitresAsync(book));
            RunCreditCardPaymentProcess = new RelayCommand(CreditCardInfo);
            ShowCreditCardView = new RelayCommand<Book>(book => _navigationService.Navigate("CreditCardPurchase", XParameters.Create("BookEntity", book)), book => book != null);
            BuyBookFromMicrosoft = new RelayCommand(BuyBookFromMicrosoftAsync);
            Read = new RelayCommand<Book>(book =>
            {
                if (!book.IsExpiredBook)
                    _navigationService.Navigate("Reader", XParameters.Create("BookEntity", book), false);
                else new MessageDialog("Истёк срок выдачи.").ShowAsync();
            });

        }