Ejemplo n.º 1
0
        public FavoritesPage()
        {
            InitializeComponent();
            var viewModel = new FavoritesViewModel();

            BindingContext = viewModel;
        }
        /// <summary>
        /// Handles the Tapped event of the AddToFavorites control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="TappedRoutedEventArgs"/> instance containing the event data.</param>
        private async void AddToFavorites_Tapped(object sender, TappedRoutedEventArgs e)
        {
            FavoritesViewModel fvm = new FavoritesViewModel();

            if (!new Connection().IsInternetConnected)
            {
                ShowToastNotification("No internet", "You need an internet connection to add or remove a movie from favorites.");
            }

            if (CheckIfMovieIsFavorite(_movieId)) // Delete from db
            {
                var response = await fvm.DeleteMovieFromDb(_movieId);

                if (response)
                {
                    User.FavoriteMoviesIds.Remove(_movieId);
                }
            }
            else //Add to db
            {
                var movie = await _mdvm.Lookup(_movieId);

                if (movie.Count == 0)
                {
                    return;
                }
                var response = await fvm.InsertMovieInDb(movie[0].MovieId, movie[0].MovieName, movie[0].ImageReference);

                if (response)
                {
                    User.FavoriteMoviesIds.Add(_movieId);
                }
            }
            CheckIfMovieIsFavorite(_movieId);
        }
Ejemplo n.º 3
0
        public void NoDataTest()
        {
            var catsStorage = new CatsStorage();

            catsStorage.Cats = new List <ImageModel>
            {
                new ImageModel(27, String.Empty, String.Empty, String.Empty),
                new ImageModel(37, String.Empty, String.Empty, String.Empty),
            };

            var vm = new FavoritesViewModel(catsStorage);

            vm.Init(null);

            Assert.AreEqual(vm.CurrentState, State.NoData);

            catsStorage.CatsFavoritesIds = new List <int>
            {
                55
            };

            vm.Init(null);

            Assert.AreEqual(vm.CurrentState, State.NoData);

            catsStorage.CatsFavoritesIds = new List <int>
            {
                catsStorage.Cats.First().Id
            };

            vm.Init(null);

            Assert.AreEqual(vm.CurrentState, State.Normal);
        }
Ejemplo n.º 4
0
 public FavoritesPage(MainWindow mainWindow)
 {
     this.mainWindow = mainWindow;
     vm = FavoritesVmSerializer.DeserializeJson();
     InitializeComponent();
     this.DataContext = vm;
 }
 public HomeViewModel()
 {
     Welcome = new WelcomeViewModel();
     Sessions = new SessionsViewModel();            
     Twitter = new TwitterViewModel();
     Favorites = new FavoritesViewModel();
 }
Ejemplo n.º 6
0
 public HomeViewModel()
 {
     Welcome   = new WelcomeViewModel();
     Sessions  = new SessionsViewModel();
     Twitter   = new TwitterViewModel();
     Favorites = new FavoritesViewModel();
 }
Ejemplo n.º 7
0
 public MainPageViewModel(MostViewedViewModel mostViewed,
                          FavoritesViewModel favorites,
                          AboutViewModel about)
 {
     MostViewed = mostViewed;
     Favorites  = favorites;
     About      = about;
 }
Ejemplo n.º 8
0
        public FavoritesViewPage()
        {
            InitializeComponent();

            BindingContext = new FavoritesViewModel();
            var vm = (FavoritesViewModel)BindingContext;

            CreateBindings(vm);
        }
Ejemplo n.º 9
0
        protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            var viewModel = new FavoritesViewModel(App.Current.FavoritesRepository, true);

            DataContext = viewModel;
            InstructionsText.Visibility = viewModel.IsEmpty ? Visibility.Visible : Visibility.Collapsed;
        }
 void BuildDependencies()
 {
     _networkController  = new NetworkController();
     _favoritesDataStore = new FavoritesDataStore();
     _downloadsDataStore = new DownloadsDataStore();
     _favVM    = new FavoritesViewModel(_favoritesDataStore, _downloadsDataStore);
     _dlVM     = new DownloadsViewModel(_downloadsDataStore, _favoritesDataStore);
     _latestVM = new LatestVideosViewModel(_networkController, _favoritesDataStore, _downloadsDataStore);
 }
Ejemplo n.º 11
0
 public FavoritesPage()
 {
     InitializeComponent();
     typeOfAdsPage            = "favorites";
     Title                    = "Spremljeni oglasi";
     BindingContext           = viewModel = new FavoritesViewModel();
     AdverismentDataStore     = DependencyService.Get <IDataStore <Advertisement> >() ?? new AdvertismentDataStorage();
     UserDataStore            = DependencyService.Get <IDataStore <FirebaseUser> >() ?? new UserDataStore();
     UserFavoriteAdsDataStore = DependencyService.Get <IDataStore <UserFavoriteAd> >() ?? new FavoritesDataStore();
 }
Ejemplo n.º 12
0
 /// <summary>
 /// Loads all the data from the database and into memory.
 /// </summary>
 private void Load()
 {
     using (var db = new DataContext())
     {
         var query = db.Favorites.Include(favorite => favorite.Url);
         this._favorites           = query.ToDictionary(entry => entry.Id, entry => entry);
         this._favoritesViewModels = new BindingList <FavoritesViewModel>(
             query.AsEnumerable().Select(fav => FavoritesViewModel.FromFavoritesLocation(fav, this._faviconCache)).ToList());
     }
 }
Ejemplo n.º 13
0
        public MainWindow()
        {
            InitializeComponent();
            vm = (WindowViewModel)this.DataContext;
            FavoritesPage favoPage = new FavoritesPage(this);

            FavoriteFrame.Navigate(favoPage);
            favoVm     = (FavoritesViewModel)favoPage.DataContext;
            foreWindow = WinApi.GetForegroundWindow();
        }
Ejemplo n.º 14
0
        public IActionResult MyFavorites()
        {
            var repo  = new FavoritesRepository();
            var model = new FavoritesViewModel();


            model.TupleList = repo.GetAllFavorites();


            return(View(model));
        }
Ejemplo n.º 15
0
        protected override void OnStart()
        {
            base.OnStart();

            viewModel = new FavoritesViewModel(Android.Application.SharedFavoritesRepository, groupByLastName: false);

            ListAdapter = new PeopleGroupsAdapter()
            {
                ItemsSource = viewModel.Groups,
            };
        }
Ejemplo n.º 16
0
 private void TextBlock_MouseUp_FromFavorites(object sender, MouseButtonEventArgs e)
 {
     if (((FavoritesViewModel)FavoritesTab.DataContext).IsClosed == true)
     {
         FavoritesViewModel dataContext   = (FavoritesViewModel)FavoritesTab.DataContext;
         DetailsViewModel   detailsModel  = new DetailsViewModel(Mediator.Instance, dataContext.SelectedMovie);
         MovieDetailsWindow detailsWindow = new MovieDetailsWindow();
         detailsWindow.DataContext = detailsModel;
         detailsWindow.Show();
     }
 }
Ejemplo n.º 17
0
        public MainWindow()
        {
            InitializeComponent();

            MoviesViewModel    moviesModel    = new MoviesViewModel(Mediator.Instance, new MessageBoxService());
            FavoritesViewModel favoritesModel = new FavoritesViewModel(Mediator.Instance, new MessageBoxService());
            WatchedViewModel   watchedModel   = new WatchedViewModel(Mediator.Instance, new MessageBoxService());

            MoviesTab.DataContext    = moviesModel;
            FavoritesTab.DataContext = favoritesModel;
            WatchedTab.DataContext   = watchedModel;
        }
Ejemplo n.º 18
0
        private void MainView_Loaded(object sender, RoutedEventArgs e)
        {
            // Must be created first since other ViewModel could use this ViewModel
            conversationStreamViewModel = new ConversationStreamViewModel();
            conversationStreamViewModel.SetScrollViewer(UIConversationStreamScrollViewer);
            UIConversationStream.DataContext = conversationStreamViewModel;

            conversationsViewModel          = new ConversationsLightViewModel();
            UIConversationsList.DataContext = conversationsViewModel;

            favoritesViewModel          = new FavoritesViewModel();
            UIFavoritesList.DataContext = favoritesViewModel;
        }
Ejemplo n.º 19
0
        public async Task <IActionResult> RemoveItem(int id)
        {
            FavoritesDAL FaveDAL = _applicationDbContext.Favorites
                                   .Where(favorite => favorite.FaveId == id).FirstOrDefault();

            _applicationDbContext.Favorites.Remove(FaveDAL);
            _applicationDbContext.SaveChanges();

            var user = await _userManager.GetUserAsync(User);

            //new list of tasks to display w/USER ID!!
            var viewModel = new FavoritesViewModel();

            viewModel.Favorites = MapFavoritesList(user.Id);

            return(View("Favorites", viewModel));
        }
Ejemplo n.º 20
0
        public async Task <IActionResult> ViewSingle(int id, double distance = 0.0D)
        {
            string userId   = User.FindFirst(ClaimTypes.NameIdentifier).Value;
            var    thisUser = _context.AspNetUsers.FirstOrDefault(x => x.Id == userId);
            //INSERT call to Mike's code here, MAYBE, that COULD return similar startups from the API and write them to a list of our Startup model
            //OR we could add a list of API startup model to the viewmodel class, filter by what Mike's code returns, and pass that on...
            //INSERT call to Jesse's code here, that will return an int for successViewStartupFavorite view = new ViewStartupFavorite() {

            List <PredictedApiStartup> topMatching = await CompareSuccess(id);

            Models.Startup startupToView = _context.Startup.Find(id);
            string         nameToSearch  = startupToView.Name.Replace(" ", "+");
            NewsResult     searchResult  = (await Utilities.GetApiResponse <NewsResult>("v2", "everything", "https://newsapi.org", "apiKey", NewsApiKey, "q", nameToSearch)).FirstOrDefault(); //       "v0 /appFo187B73tuYhyg", "Master List", "https://api.airtable.com", "api_key", ApiKey)).FirstOrDefault();
            List <Article> articles      = new List <Article>();

            for (int i = 0; i < 5; i++)
            {
                try
                {
                    articles.Add(searchResult.articles[i]);
                }
                catch
                {
                    continue;
                }
            }


            FavoritesViewModel view = new FavoritesViewModel()
            {
                SingleStartupToView       = startupToView,
                FavoriteStartups          = _context.Favorites.Where(x => x.UserId == userId).ToList <Favorites>(),
                UserAssociation           = thisUser.Association,
                MatchingPredictedStartups = topMatching,
                Comments = _context.Comment.Where(x => x.StartupId == id &&
                                                  x.Restricted == false).ToList <Comment>(),
                ExclusiveComments = _context.Comment.Where(x => x.StartupId == id &&
                                                           x.Restricted == true &&
                                                           x.Association == thisUser.Association).ToList <Comment>(),
                Articles = articles
            };

            ViewBag.Distance = distance;

            return(View(view));
        }
Ejemplo n.º 21
0
        public FavoritesViewController(IFavoritesRepository favoritesRepository, IDirectoryService service, Search savedSearch)
        {
            this.favoritesRepository = favoritesRepository;

            Title = "Favorites";

            viewModel = new FavoritesViewModel(favoritesRepository, groupByLastName: true);
            viewModel.PropertyChanged += HandleViewModelPropertyChanged;

            searchViewModel = new SearchViewModel(service, savedSearch);

            //
            // Configure this view
            //
            var favoritesDelegate = new PeopleGroupsDelegate(TableView);

            favoritesDelegate.PersonSelected += HandlePersonSelected;

            TableView.DataSource = new PeopleGroupsDataSource(viewModel.Groups);
            TableView.Delegate   = favoritesDelegate;
            TableView.SectionIndexMinimumDisplayRowCount = 10;

            //
            // Configure the search bar
            //
            searchBar = new UISearchBar(new CGRect(0, 0, 320, 44))
            {
                ShowsScopeBar = true,
            };

            searchBar.ScopeButtonTitles        = new[] { "Name", "Title", "Dept", "All" };
            searchBar.SelectedScopeButtonIndex = (int)savedSearch.Property;
            searchController = new UISearchDisplayController(searchBar, this)
            {
                SearchResultsDataSource = new PeopleGroupsDataSource(searchViewModel.Groups),
                Delegate = new SearchDisplayDelegate(searchViewModel)
            };

            var searchDelegate = new PeopleGroupsDelegate(searchController.SearchResultsTableView);

            searchController.SearchResultsTableView.SectionIndexMinimumDisplayRowCount = 10;
            searchDelegate.PersonSelected         += HandleSearchPersonSelected;
            searchController.SearchResultsDelegate = searchDelegate;

            TableView.TableHeaderView = searchBar;
        }
Ejemplo n.º 22
0
        public FavoritesPage()
        {
            this.InitializeComponent();
            ViewModel = DataContext as FavoritesViewModel;

            //Doing this in code-behind, because doing it in XAML breaks the XAML designer.
            var collectionViewSourceBinding = new Binding();

            collectionViewSourceBinding.Source = ViewModel.Favorites;
            collectionViewSourceBinding.Mode   = BindingMode.OneWay;

            BindingOperations.SetBinding(FavoritesViewSource,
                                         CollectionViewSource.SourceProperty,
                                         collectionViewSourceBinding);

            this.Unloaded += FavoritesPage_Unloaded;
        }
Ejemplo n.º 23
0
        /// <summary>
        /// The mock get or create.
        /// </summary>
        /// <param name="url">
        /// The url.
        /// </param>
        /// <returns>
        /// The <see cref="FavoritesLocation"/>.
        /// </returns>
        public FavoritesLocation GetOrCreate(Url url)
        {
            var inDb = this._idLookup.SingleOrDefault(pair => pair.Value.Url == url);

            if (inDb.Value != null)
            {
                return(inDb.Value);
            }

            var loc = new FavoritesLocation(url);

            this._viewModel.Add(FavoritesViewModel.FromFavoritesLocation(loc, new MockFaviconCache()));
            this._idLookup.Add(this.id, loc);
            this.OnFavoritesAddOrUpdate?.Invoke(this, new FavoritesUpdateEventArgs(loc));
            loc.Id = this.id++;
            return(loc);
        }
Ejemplo n.º 24
0
        public IActionResult FavoritesIndex()
        {
            var dbModel = new RecipeDAL();

            var RecipeList = _recipeDbContext.Favorites
                             .Select(recipeDAL => new ResultsViewModel()
            {
                ID = recipeDAL.ID, title = recipeDAL.title, href = recipeDAL.href, thumbnail = recipeDAL.thumbnail
            })
                             .ToList();

            var viewModel = new FavoritesViewModel();

            viewModel.results = RecipeList;

            return(View(viewModel));
        }
Ejemplo n.º 25
0
        /// <summary>
        /// Updates the item in memory with the same id with new data.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="args">
        /// The args.
        /// </param>
        private void UpdateFavorites(object sender, FavoritesUpdateEventArgs args)
        {
            // update favorites
            this._favorites[args.Location.Id] = args.Location;

            // update viewmodel
            var toUpdate = this._favoritesViewModels.SingleOrDefault(model => model.Url == args.Location.Url.ToString());

            if (toUpdate == null)
            {
                this._favoritesViewModels.Add(FavoritesViewModel.FromFavoritesLocation(args.Location, this._faviconCache));
            }
            else
            {
                toUpdate.Name = args.Location.Name;
                toUpdate.Url  = args.Location.Url.ToString();
            }
        }
        public IActionResult Favorites()
        {
            IList <FavoritesViewModel> vmList        = new List <FavoritesViewModel>();
            IList <SurveyData>         favoriteParks = new List <SurveyData>();

            favoriteParks = _db2.GetSurveyParks();
            foreach (SurveyData sd in favoriteParks)
            {
                Park newPark          = _db2.GetPark(sd.ParkCode);
                FavoritesViewModel vm = new FavoritesViewModel();
                vm.NumVotes        = sd.NumVotes;
                vm.ParkCode        = sd.ParkCode;
                vm.ParkName        = newPark.ParkName;
                vm.ParkDescription = newPark.ParkDescription;
                vmList.Add(vm);
            }
            return(View(vmList));
        }
Ejemplo n.º 27
0
        public IActionResult Favorites()
        {
            IList <FavoritesViewModel> vmList = new List <FavoritesViewModel>();
            IList <SurveyResultModel>  rmList = new List <SurveyResultModel>();

            rmList = _surveyDAO.GetAllSurveys();
            foreach (SurveyResultModel RM in rmList)
            {
                FavoritesViewModel vm   = new FavoritesViewModel();
                ParkModel          park = _parkDAO.GetPark(RM.ParkCode);
                vm.NumVotes = RM.NumVotes;
                vm.ParkCode = RM.ParkCode;
                vm.ParkName = park.ParkName;
                vm.ParkDesc = park.ParkDescription;
                vmList.Add(vm);
            }
            return(View("Favorites", vmList));
        }
		public FavoritesPage()
		{
			InitializeComponent();

			BindingContext = new FavoritesViewModel();

			listView.SeparatorVisibility = SeparatorVisibility.Default;
			listView.SeparatorColor = Color.FromHex("#ababab");

			listView.ItemTapped += (sender, args) =>
			{
				if (listView.SelectedItem == null)
					return;
				
				//do nothing anyway
				return;
			};

		}
Ejemplo n.º 29
0
        public FavoritesPage()
        {
            InitializeComponent();
            BindingContext = viewModel = new FavoritesViewModel();

            this.CitiesListView.ItemSelected += async(object sender, SelectedItemChangedEventArgs e) =>
            {
                if (e.SelectedItem == null)
                {
                    return;
                }

                var city = e.SelectedItem as City;
                MessagingCenter.Send(this, App.SELECT_CITY_MESSAGE, city);
                await Navigation.PopModalAsync(true);

                this.CitiesListView.SelectedItem = null;
            };
        }
Ejemplo n.º 30
0
		public Issue3319 ()
		{
			#if APP
			InitializeComponent ();
			BindingContext = new FavoritesViewModel ();

			listView.SeparatorVisibility = SeparatorVisibility.Default;
			listView.SeparatorColor = Color.FromHex ("#ababab");

			listView.ItemTapped += (sender, args) => {
				if (listView.SelectedItem == null)
					return;

				//do nothing anyway
				return;
			};
			#endif

		}
Ejemplo n.º 31
0
        protected async override void OnAppearing()
        {
            base.OnAppearing();

            if (LoginViewModel.ShouldShowLogin(App.LastUseTime))
            {
                await Navigation.PushModalAsync(new LoginView());
            }

            favoritesRepository = await XmlFavoritesRepository.OpenIsolatedStorage("XamarinFavorites.xml");

            if (favoritesRepository.GetAll().Count() == 0)
            {
                favoritesRepository = await XmlFavoritesRepository.OpenFile("XamarinFavorites.xml");
            }

            viewModel            = new FavoritesViewModel(favoritesRepository, true);
            listView.ItemsSource = viewModel.Groups;
        }
Ejemplo n.º 32
0
        public async Task <IActionResult> Favorites()
        {
            var viewModel = new FavoritesViewModel();

            var user = await _userManager.GetUserAsync(User);

            var favorites = _applicationDbContext.Favorites
                            .Where(favorite => favorite.Id == user.Id).ToList();

            viewModel.Favorites = favorites.Select(faveDAL => new Recipe
            {
                ID          = faveDAL.FaveId,
                title       = faveDAL.Title,
                ingredients = faveDAL.Ingredients,
                href        = faveDAL.href
            }).ToList();

            return(View(viewModel));
        }