Esempio n. 1
0
        public int AddReview(Review review)
        {
            RestaurantsDbEntities dbutilities = new RestaurantsDbEntities();

            dbutilities.Reviews.Add(review);
            dbutilities.SaveChanges();
            return(review.id);
        }
Esempio n. 2
0
        public int AddRestaurant(Restaurant r)
        {
            RestaurantsDbEntities dbutilities = new RestaurantsDbEntities();

            dbutilities.Restaurants.Add(r);
            dbutilities.SaveChanges();
            return(r.id);
        }
Esempio n. 3
0
        public void DeleteRestaurant(int id)
        {
            RestaurantsDbEntities dbutilities = new RestaurantsDbEntities();
            Restaurant            r           = GetRestaurantModels().SingleOrDefault(x => x.id == id);

            dbutilities.Restaurants.Attach(r);
            dbutilities.Restaurants.Remove(r);
            dbutilities.SaveChanges();
        }
Esempio n. 4
0
        public void DeleteReview(int ReviewId)
        {
            RestaurantsDbEntities dbutilities = new RestaurantsDbEntities();
            Review review = GetReviewModels().SingleOrDefault(x => x.id == ReviewId);

            dbutilities.Reviews.Attach(review);
            dbutilities.Reviews.Remove(review);
            dbutilities.SaveChanges();
        }
Esempio n. 5
0
        public void EditReview(Review r, int ReviewId)
        {
            RestaurantsDbEntities dbutilities = new RestaurantsDbEntities();
            Review review = GetReviewModels().SingleOrDefault(x => x.id == ReviewId);

            review.reviewer = r.reviewer;
            review.rating   = r.rating;
            review.comments = r.comments;
            dbutilities.Reviews.Attach(review);
            dbutilities.Entry(review).State = EntityState.Modified;
            dbutilities.SaveChanges();
        }
Esempio n. 6
0
        public void EditRestaurant(Restaurant restaurant, int restaurantId)
        {
            RestaurantsDbEntities dbutilities = new RestaurantsDbEntities();
            Restaurant            rest        = GetRestaurantModels().SingleOrDefault(x => x.id == restaurantId);

            rest.name    = restaurant.name;
            rest.address = restaurant.address;

            dbutilities.Restaurants.Attach(rest);
            dbutilities.Entry(rest).State = EntityState.Modified;
            dbutilities.SaveChanges();
        }
        public void DeleteRestaurant(int id)
        {
            RestaurantsDbEntities dbutilities = new RestaurantsDbEntities();

            try
            {
                Restaurant r = dbutilities.Restaurants.Find(id);
                dbutilities.Restaurants.Remove(r);
                dbutilities.SaveChanges();
            } catch (Exception ex)
            {
                throw ex;
            }
        }