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); }
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); }
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(); }
public MainPageViewModel(MostViewedViewModel mostViewed, FavoritesViewModel favorites, AboutViewModel about) { MostViewed = mostViewed; Favorites = favorites; About = about; }
public FavoritesViewPage() { InitializeComponent(); BindingContext = new FavoritesViewModel(); var vm = (FavoritesViewModel)BindingContext; CreateBindings(vm); }
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); }
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(); }
/// <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()); } }
public MainWindow() { InitializeComponent(); vm = (WindowViewModel)this.DataContext; FavoritesPage favoPage = new FavoritesPage(this); FavoriteFrame.Navigate(favoPage); favoVm = (FavoritesViewModel)favoPage.DataContext; foreWindow = WinApi.GetForegroundWindow(); }
public IActionResult MyFavorites() { var repo = new FavoritesRepository(); var model = new FavoritesViewModel(); model.TupleList = repo.GetAllFavorites(); return(View(model)); }
protected override void OnStart() { base.OnStart(); viewModel = new FavoritesViewModel(Android.Application.SharedFavoritesRepository, groupByLastName: false); ListAdapter = new PeopleGroupsAdapter() { ItemsSource = viewModel.Groups, }; }
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(); } }
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; }
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; }
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)); }
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)); }
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; }
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; }
/// <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); }
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)); }
/// <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)); }
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; }; }
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; }; }
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 }
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; }
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)); }