public HubPageViewModel.ProfileInfo GetProfileData(int id, int userid) { HubPageViewModel.ProfileInfo profil = db.Korisnics.Where(x => x.Id == id).Select(z => new HubPageViewModel.ProfileInfo { KorisnikID = z.Id, username = z.username, Joined = z.created_at, Grad = z.Grad, FriendCount = z.Prijateljstvos.Count(), ImePrezime = z.Ime + " " + z.Prezime, Email = z.Email }).FirstOrDefault(); int br = db.Prijateljstvos.Where(x => x.Korisnik1ID == userid && x.Korisnik2ID == id).Count(); profil.IsFriend = br > 0; List <HubPageViewModel.ShelvesInfo.ShelfInfo> police = db.Policas.Where(x => x.KorisnikID == id).Select(p => new HubPageViewModel.ShelvesInfo.ShelfInfo { BookCount = p.Knjigas.Count(), KorisnikID = p.KorisnikID, Naziv = p.Naziv, ShelfID = p.Id }).ToList(); HubPageViewModel.ShelvesInfo.ShelfInfo polica = police.Where(x => x.Naziv == "Currently Reading").FirstOrDefault(); if (polica != null) { Polica gk = db.Policas.Include("Knjigas").Where(c => c.Id == polica.ShelfID).FirstOrDefault(); List <Knjiga> curb = gk.Knjigas; if (curb != null) { profil.CurrentlyReadingBooks = new List <HubPageViewModel.ProfileInfo.BookInfo>(); profil.CurrentlyReadingBooks = curb.Select(k => new HubPageViewModel.ProfileInfo.BookInfo { Autor = "Neki Autor", KnjigaID = k.Id, Naslov = k.Naslov, Slika = k.Slika }).ToList(); } else { profil.CurrentlyReadingBooks = null; } } else { profil.CurrentlyReadingBooks = null; } return(profil); }
private void addfriendbtn_Click(object sender, RoutedEventArgs e) { HubPageViewModel.ProfileInfo profil = (HubPageViewModel.ProfileInfo)defaultViewModel["profil"]; HttpResponseMessage response = prijateljService.GetResponse(profil.KorisnikID + "/" + Global.prijavljeniKorisnik.Id); if (response.IsSuccessStatusCode) { MessageDialog msg = new MessageDialog("Prijatelj uspješno dodan!"); msg.ShowAsync(); Frame.Navigate(typeof(ProfilPage), profil.KorisnikID); } }
/// <summary> /// Populates the page with content passed during navigation. Any saved state is also /// provided when recreating a page from a prior session. /// </summary> /// <param name="sender"> /// The source of the event; typically <see cref="NavigationHelper"/> /// </param> /// <param name="e">Event data that provides both the navigation parameter passed to /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested and /// a dictionary of state preserved by this page during an earlier /// session. The state will be null the first time a page is visited.</param> private void NavigationHelper_LoadState(object sender, LoadStateEventArgs e) { HttpResponseMessage response = profilService.GetResponse(e.NavigationParameter.ToString() + "/" + Global.prijavljeniKorisnik.Id); if (response.IsSuccessStatusCode) { HubPageViewModel.ProfileInfo profil = response.Content.ReadAsAsync <HubPageViewModel.ProfileInfo>().Result; defaultViewModel["profil"] = profil; if (profil.IsFriend || profil.KorisnikID == Global.prijavljeniKorisnik.Id) { addfriendbtn.Visibility = Visibility.Collapsed; } } }
private void Button_Click(object sender, RoutedEventArgs e) { HubPageViewModel.ProfileInfo profil = (HubPageViewModel.ProfileInfo)defaultViewModel["profil"]; Frame.Navigate(typeof(PrijateljiPage), profil.KorisnikID); }