// UPDATE public async Task UpdateReviewAsync(string reviewerName, string comment, int foodRating, int serviceRating, int priceRating, int atmosphereRating, int restaurantID) { ReviewAccessor reviewCRUD = new ReviewAccessor(); try { // Check restaurantID -- Will throw exception if invalid Restaurant rest = Restaurant.GetRestaurantByID(restaurantID); // Conform rating input to rating bounds foodRating = foodRating < 0 ? 0 : (foodRating > 5 ? 5 : foodRating); serviceRating = serviceRating < 0 ? 0 : (serviceRating > 5 ? 5 : serviceRating); priceRating = priceRating < 0 ? 0 : (priceRating > 5 ? 5 : priceRating); atmosphereRating = atmosphereRating < 0 ? 0 : (atmosphereRating > 5 ? 5 : atmosphereRating); await reviewCRUD.UpdateReviewAsync(this.ID, reviewerName, comment, foodRating, serviceRating, priceRating, atmosphereRating, restaurantID); } catch { throw; } }
// READ public static List <Review> GetReviews() { ReviewAccessor reviewCRUD = new ReviewAccessor(); List <DL.Review> dataList = reviewCRUD.GetReviews().ToList(); List <Review> result = dataList.Select(x => DataToLibrary(x)).ToList(); return(result); }
// DELETE public async Task DeleteReviewAsync() { ReviewAccessor reviewCRUD = new ReviewAccessor(); try { await reviewCRUD.DeleteReviewAsync(this.ID); } catch { throw; } }
public static List <Review> GetReviewsByRestaurantID(int restID) { ReviewAccessor reviewCRUD = new ReviewAccessor(); try { return(reviewCRUD.GetReviewsByRestaurantID(restID).Select(x => DataToLibrary(x)).ToList()); } catch { throw; } }
public static Review GetReviewByID(int id) { ReviewAccessor reviewCRUD = new ReviewAccessor(); Review r; try { r = DataToLibrary(reviewCRUD.GetReviewByID(id)); } catch { throw; } return(r); }
/* * checks if the customer has already left a review on a specified book */ public bool CheckReview(int customerID, string isbn) { try { if (ReviewAccessor.CheckReview(customerID, isbn) >= 1) { return(true); } } catch (Exception) { throw; } return(false); }
public bool DeleteReview(Review review, bool toRestore) { try { if (ReviewAccessor.InactivateReview(review, toRestore)) { return(true); } } catch (Exception) { throw; } return(false); }
public bool EditReview(Review review) { try { if (ReviewAccessor.UpdateReview(review)) { return(true); } } catch (Exception) { throw; } return(false); }
public bool AddReview(Review review) { try { if (ReviewAccessor.InsertReview(review)) { return(true); } } catch (Exception) { throw; } return(false); }
public List <Review> GetReviewList(Active group) { try { var reviewList = ReviewAccessor.FetchReviewList(group); if (reviewList.Count > 0) { return(reviewList); } else { throw new ApplicationException("There were no records found."); } } catch (Exception) { throw; } }
public ReviewRepository(LocalGourmetDBEntities db) { crud = new ReviewAccessor(db); }
public ReviewRepository() { crud = new ReviewAccessor(); }
// CREATE public async Task AddReviewAsync() { DL.Review review = LibraryToData(this); ReviewAccessor ra = new ReviewAccessor(); await ra.AddReviewAsync(review); }