private async Task CategoryListAppears() { //-------------- To show Donation Adverts on the main page var donationAdverts = await advertViewModel.GetDonationAdverts(); //List reversed to show people last adverts. donationAdverts.Reverse(); foreach (var item in donationAdverts) { if (!DonationAdverts.Any((arg) => arg.AdvertID == item.AdvertID)) { if ((item.BookCategory.ToString() == CategoryName.Text)) { DonationAdverts.Add(item); } } } //------------------------------------------------------------------------ //-------------- To show Donation Adverts on the main page var exchangeAdverts = await advertViewModel.GetExchangeAdverts(); //List reversed to show people last adverts. exchangeAdverts.Reverse(); foreach (var item in exchangeAdverts) { if (!ExchangeAdverts.Any((arg) => arg.AdvertID == item.AdvertID)) { if ((item.BookCategory.ToString() == CategoryName.Text)) { ExchangeAdverts.Add(item); } } } //------------------------------------------------------------------------ }
private async Task HomePageAppears() { var Mainapp = Application.Current as App; var messages = await advertViewModel.GetMessages(); messages.Reverse(); foreach (var item in messages) { if (!Messages.Any((arg) => arg.Id == item.Id)) { if (!Messages.Any((arg) => item.Sender == arg.Sender && item.SpecialBookName == arg.SpecialBookName)) { if ((item.Receiver.ToString() == Mainapp.Email)) { Messages.Add(item); } } } } //-------------- To show Donation Adverts on the main page var donationAdverts = await advertViewModel.GetDonationAdverts(); //List reversed to show people last adverts. donationAdverts.Reverse(); foreach (var item in donationAdverts) { if (!DonationAdverts.Any((arg) => arg.AdvertID == item.AdvertID)) { DonationAdverts.Add(item); } } //------------------------------------------------------------------------ //-------------- To show Donation Adverts on the main page var exchangeAdverts = await advertViewModel.GetExchangeAdverts(); //List reversed to show people last adverts. exchangeAdverts.Reverse(); foreach (var item in exchangeAdverts) { if (!ExchangeAdverts.Any((arg) => arg.AdvertID == item.AdvertID)) { ExchangeAdverts.Add(item); } } //------------------------------------------------------------------------ //To show profile information to user using saved email UserViewModel userView = new UserViewModel(); var app = Application.Current as App; User user; try { user = await userView.GetUserByEmail(app.Email); profileTabName.Text = user.name; profileTabLocation.Text = user.city + "/" + user.district; profileTabEmail.Text = user.email; changeName.Text = user.name; changeEmail.Text = user.email; changeLocation.Text = user.city + "/" + user.district; userImage.Source = ImageSource.FromStream(() => new MemoryStream(user.image)); } catch (Exception ex) { PopUpTitle.Text = "User not found!"; PopUpLabel.Text = ex.Message; popUpImageView.IsVisible = true; } }