public void RemoveReview(int id) { CinemaReview reviewFromDb = _cinemaDbContext.CinemaReviews.FirstOrDefault(x => x.ReviewId == id); if (reviewFromDb != null) { _cinemaDbContext.Remove(reviewFromDb); _cinemaDbContext.SaveChanges(); } }
public async Task AddUpdateCinemaReview(CinemaReview cinemaReview) { if (cinemaReview.Id != 0) { await MobileService.GetTable <CinemaReview>().UpdateAsync(cinemaReview); } else { await MobileService.GetTable <CinemaReview>().InsertAsync(cinemaReview); } }
public ReviewDTO GetReviewByReviewId(int reviewId) { CinemaReview reviewFromDB = _cinemaDbContext.CinemaReviews.FirstOrDefault(x => x.ReviewId == reviewId); return(new ReviewDTO { MovieId = reviewFromDB.MovieId, Review = reviewFromDB.Review, ReviewId = reviewFromDB.ReviewId, UserId = reviewFromDB.UserId, }); }
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(); } }