Ejemplo n.º 1
0
        // 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;
            }
        }
Ejemplo n.º 2
0
        // 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);
        }
Ejemplo n.º 3
0
        // DELETE
        public async Task DeleteReviewAsync()
        {
            ReviewAccessor reviewCRUD = new ReviewAccessor();

            try
            {
                await reviewCRUD.DeleteReviewAsync(this.ID);
            }
            catch
            {
                throw;
            }
        }
Ejemplo n.º 4
0
        public static List <Review> GetReviewsByRestaurantID(int restID)
        {
            ReviewAccessor reviewCRUD = new ReviewAccessor();

            try
            {
                return(reviewCRUD.GetReviewsByRestaurantID(restID).Select(x => DataToLibrary(x)).ToList());
            }
            catch
            {
                throw;
            }
        }
Ejemplo n.º 5
0
        public static Review GetReviewByID(int id)
        {
            ReviewAccessor reviewCRUD = new ReviewAccessor();
            Review         r;

            try
            {
                r = DataToLibrary(reviewCRUD.GetReviewByID(id));
            }
            catch
            {
                throw;
            }
            return(r);
        }
Ejemplo n.º 6
0
        /*
         * 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);
        }
Ejemplo n.º 7
0
        public bool DeleteReview(Review review, bool toRestore)
        {
            try
            {
                if (ReviewAccessor.InactivateReview(review, toRestore))
                {
                    return(true);
                }
            }
            catch (Exception)
            {
                throw;
            }

            return(false);
        }
Ejemplo n.º 8
0
        public bool EditReview(Review review)
        {
            try
            {
                if (ReviewAccessor.UpdateReview(review))
                {
                    return(true);
                }
            }
            catch (Exception)
            {
                throw;
            }

            return(false);
        }
Ejemplo n.º 9
0
        public bool AddReview(Review review)
        {
            try
            {
                if (ReviewAccessor.InsertReview(review))
                {
                    return(true);
                }
            }
            catch (Exception)
            {
                throw;
            }

            return(false);
        }
Ejemplo n.º 10
0
        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();
 }
Ejemplo n.º 13
0
 // CREATE
 public async Task AddReviewAsync()
 {
     DL.Review      review = LibraryToData(this);
     ReviewAccessor ra     = new ReviewAccessor();
     await ra.AddReviewAsync(review);
 }