/// <summary> /// Get property of source to work on. /// </summary> /// <exception cref="ArgumentNullException"> /// When propertyLambda is null. /// </exception> /// <exception cref="ArgumentException"> /// When propertyLambda does not select a proeprty /// </exception> /// <typeparam name="TProperty">Type of property.</typeparam> /// <param name="propertyLambda">Lambda expression to get property.</param> /// <returns>Extended property helper to be able to work on property.</returns> public ExtendedPropertyHelper <TEntity> ExtendedProperty <TProperty>( Expression <Func <TEntity, TProperty> > propertyLambda) { if (propertyLambda == null) { throw new ArgumentNullException("propertyLambda"); } var property = propertyLambda.GetPropertyInfo(); if (property == null) { throw new ArgumentException(string.Format( "Expression '{0}' does not select any property", propertyLambda.ToString())); } var helper = new ExtendedPropertyHelper <TEntity>(property); return(helper); }
private async void LogBookingStats(object sender, RoutedEventArgs e) { MenuItem miBuy = (sender as MenuItem); miBuy.Click -= this.LogBookingStats; try { MenuItem mi = sender as MenuItem; if (mi != null) { ContextMenu cm = mi.Parent as ContextMenu; PerformanceInfo pi = (PerformanceInfo)cm.Tag; BookingHistory bh = new BookingHistory(pi); bh.UserId = ExtendedPropertyHelper.GetUserIdentifier(); await App.MobileService.GetTable <BookingHistory>().InsertAsync(bh); } } catch { } }
protected async override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); this.SpinAndWait(false); if (ReviewTarget == ReviewTargetDef.Film) { this.tbReviewing.Text = SelectedFilm.Title; List <FilmReview> filmreviews = null; try { filmreviews = await App.MobileService.GetTable <FilmReview>().Where(r => r.Movie == SelectedFilm.EDI && r.UserId == ExtendedPropertyHelper.GetUserIdentifier()).ToListAsync(); } catch { } if (filmreviews != null && filmreviews.Count > 0) { this.UserReview = filmreviews[0]; } else { this.UserReview = new FilmReview() { Reviewer = Config.UserName } }; } else { this.tbReviewing.Text = String.Format("Cineworld - {0}", SelectedCinema.Name); List <CinemaReview> cinemareviews = null; try { cinemareviews = await App.MobileService.GetTable <CinemaReview>().Where(r => r.Cinema == SelectedCinema.ID && r.UserId == ExtendedPropertyHelper.GetUserIdentifier()).ToListAsync(); } catch { } if (cinemareviews != null && cinemareviews.Count > 0) { this.UserReview = cinemareviews[0]; } else { this.UserReview = new CinemaReview() { Reviewer = Config.UserName } }; } this.PopulateExistingReview(); }
private async void btnSubmit_Click(object sender, EventArgs e) { if (this.rating.Value == 0) { MessageBox.Show(String.Format("please rate this {0}", ReviewTarget.ToString())); return; } this.SpinAndWait(true); this.UserReview.Reviewer = String.IsNullOrWhiteSpace(this.tbName.Text) ? "anonymous" : this.tbName.Text; this.UserReview.Review = this.tbReview.Text.Trim(); this.UserReview.Rating = Convert.ToInt16(this.rating.Value); this.UserReview.ReviewTS = DateTime.Now; this.UserReview.UserId = ExtendedPropertyHelper.GetUserIdentifier(); Config.UserName = this.UserReview.Reviewer; try { if (ReviewTarget == ReviewTargetDef.Film) { FilmReview fr = (FilmReview)this.UserReview; fr.Movie = SelectedFilm.EDI; if (this.UserReview.Id != 0) { await App.MobileService.GetTable <FilmReview>().UpdateAsync(fr); } else { await App.MobileService.GetTable <FilmReview>().InsertAsync(fr); } } else { CinemaReview cr = (CinemaReview)this.UserReview; cr.Cinema = SelectedCinema.ID; if (this.UserReview.Id != 0) { await App.MobileService.GetTable <CinemaReview>().UpdateAsync(cr); } else { await App.MobileService.GetTable <CinemaReview>().InsertAsync(cr); } } } catch { MessageBox.Show("error saving review. please try again later"); } this.SpinAndWait(false); if (this.NavigationService.CanGoBack) { this.NavigationService.GoBack(); } }
private void LoginButtonClick(object sender, RoutedEventArgs e) { servicioLogin.LoginCompleted += LoginCompleted; servicioLogin.LoginAsync(nombreUsuarioTextBox.Text, passwordTextBox.Password, ExtendedPropertyHelper.GetWindowsLiveAnonymousId()); }