public bool PostYourReview(TblTableReview tblTableReview)
        {
            if (tblTableReview != null)
            {
                db.Add(tblTableReview);
                db.SaveChanges();
                return(true);
            }

            return(false);
        }
예제 #2
0
        public bool AddRestaurantRating(RestaurantRating restaurantRating, out RestaurantRating returnedRestaurantRating)
        {
            try
            {
                if (!DoesRestaurantExists(restaurantRating.RestaurantId))
                {
                    throw new Exception("Restaurant doesn't exist! Try sending a valid Restaurant Id");
                }

                TblRating tblRating = new TblRating()
                {
                    Id = restaurantRating.RatingId,
                    TblRestaurantId        = restaurantRating.RestaurantId,
                    Rating                 = restaurantRating.rating,
                    Comments               = restaurantRating.user_Comments,
                    RecordTimeStampCreated = DateTime.Now,
                    RecordTimeStampUpdated = DateTime.Now
                };
                _dbContext.Add(tblRating);

                SaveChanges();

                returnedRestaurantRating = new RestaurantRating()
                {
                    RatingId      = tblRating.Id,
                    RestaurantId  = tblRating.TblRestaurantId,
                    rating        = tblRating.Rating,
                    user_Comments = tblRating.Comments
                };

                return(true);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }