Example #1
0
        public new void Add(Review entity)
        {
            RRRavesDBEntities.Set <Review>().Add(entity);
            int RestId = (int)entity.Restaurant;

            this.AverageRatingsAdd(RestId, entity.Rating);
        }
Example #2
0
        public void EditRestaurant(int id, string field, string newvalue)
        {
            switch (field)
            {
            case "Name":
                RRRavesDBEntities.Set <Restaurant>().Find(id).Name = newvalue;
                break;

            case "Address":
                RRRavesDBEntities.Set <Restaurant>().Find(id).Address = newvalue;
                break;

            case "City":
                RRRavesDBEntities.Set <Restaurant>().Find(id).City = newvalue;
                break;

            case "ZipCode":
                RRRavesDBEntities.Set <Restaurant>().Find(id).Zipcode = newvalue;
                break;

            case "Phone":
                RRRavesDBEntities.Set <Restaurant>().Find(id).Phone = newvalue;
                break;

            case "Website":
                RRRavesDBEntities.Set <Restaurant>().Find(id).Website = newvalue;
                break;

            default:
                break;
            }
        }
Example #3
0
 public new void RemoveRange(IEnumerable <Review> entities)
 {
     RRRavesDBEntities.Set <Review>().RemoveRange(entities);
     foreach (var item in entities)
     {
         int RestId = (int)item.Restaurant;
     }
 }
Example #4
0
 public new void AddRange(IEnumerable <Review> entities)
 {
     RRRavesDBEntities.Set <Review>().AddRange(entities);
     foreach (var item in entities)
     {
         int RestId = (int)item.Restaurant;
         this.AverageRatingsAdd(RestId, item.Rating);
     }
 }
Example #5
0
        public new void Remove(Review entity)
        {
            int RestId  = entity.Restaurant.Value;
            int OldRate = entity.Rating;

            this.AverageRatingsRemove(RestId, OldRate);

            RRRavesDBEntities.Set <Review>().Remove(entity);
        }
Example #6
0
 public new void RemoveRange(IEnumerable <Review> entities)
 {
     foreach (var item in entities)
     {
         int RestId  = (int)item.Restaurant;
         int OldRate = (int)item.Rating;
         this.AverageRatingsRemove(RestId, OldRate);
         RRRavesDBEntities.Set <Review>().Remove(item);
     }
 }
Example #7
0
        public void AverageRatingsRemove(int RestaurantID, int OldRating)
        {
            var temp  = RRRavesDBEntities.Set <Review>().Where(x => x.Restaurant == RestaurantID);
            var temp2 = temp.Select(x => x.Rating).ToList();

            temp2.Remove(OldRating);

            var temp3 = Convert.ToDecimal(temp2.DefaultIfEmpty().Average());

            RRRavesDBEntities.Set <Restaurant>().Find(RestaurantID).AveRating = temp3;
        }
Example #8
0
        public void EditReview(int id, Review r)
        {
            //var rest = RRRavesDBEntities.Set<Review>().Single(i => i.ID_Review == id);
            //if (rest != null)
            //{
            //    rest.Rating = r.Rating;
            //    rest.ReviewText = r.ReviewText;

            //}

            var oldReview = RRRavesDBEntities.Reviews.Find(id);
            var oldRate   = oldReview.Rating;

            RRRavesDBEntities.Entry(oldReview).CurrentValues.SetValues(r);
            this.AverageRatingsEdit(r.Restaurant.Value, oldRate, r.Rating);
        }
        public void EditRestaurant(int id, Restaurant restaurant)
        {
            //var rest = RRRavesDBEntities.Set<Restaurant>().Single(i => i.ID_Restaurant == id);
            //if (rest != null)
            //{
            //    rest.Name = restaurant.Name;
            //    rest.Address = restaurant.Address;
            //    rest.City = restaurant.City;
            //    rest.Zipcode = restaurant.Zipcode;
            //    rest.Phone = restaurant.Phone;
            //    rest.Website = restaurant.Website;
            //}

            var oldRest = RRRavesDBEntities.Restaurants.Find(id);

            RRRavesDBEntities.Entry(oldRest).CurrentValues.SetValues(restaurant);
        }
Example #10
0
        public void EditReview(int id, string field, string newvalue)
        {
            switch (field)
            {
            case "Rating":
                var oldRating = RRRavesDBEntities.Set <Review>().Find(id).Rating;
                RRRavesDBEntities.Set <Review>().Find(id).Rating = Convert.ToInt32(newvalue);
                var rid = (int)RRRavesDBEntities.Set <Review>().Find(id).Restaurant;
                this.AverageRatingsEdit(rid, oldRating, Convert.ToInt32(newvalue));
                break;

            case "ReviewText":
                RRRavesDBEntities.Set <Review>().Find(id).ReviewText = newvalue;
                break;

            default:
                break;
            }
        }
Example #11
0
 public new void Remove(Review entity)
 {
     RRRavesDBEntities.Set <Review>().Remove(entity);
     int RestId = (int)entity.Restaurant;
 }
Example #12
0
 public ReviewRepository(RRRavesDBEntities db) : base(db)
 {
 }
Example #13
0
 public IEnumerable <Restaurant> GetTopThree()
 {
     return(RRRavesDBEntities.Set <Restaurant>().OrderByDescending(x => x.AveRating).Take(3));
 }
Example #14
0
 public RestaurantRepository(RRRavesDBEntities db) : base(db)
 {
 }
 public new void Remove(Restaurant entity)
 {
     RRRavesDBEntities.Set <Restaurant>().Remove(entity);
 }